Category Theory
for
Computing Science

Michael Barr
Charles Wells

c(cid:176)Michael Barr and Charles Wells, 1998

Category Theory
for
Computing Science

Michael Barr
Department of Mathematics and
Statistics
McGill University

Charles Wells
Department of Mathematics
Case Western Reserve University

For
Becky, Adam and Joe
and
Matt and Peter

Contents

Preface

1 Preliminaries

Sets
Functions

1.1
1.2
1.3 Graphs
1.4 Homomorphisms of graphs

2 Categories

Functional programming languages as categories

2.1 Basic deﬁnitions
2.2
2.3 Mathematical structures as categories
2.4 Categories of sets with structure
2.5 Categories of algebraic structures
2.6 Constructions on categories
2.7 Properties of objects and arrows in a category
2.8 Monomorphisms and subobjects
2.9 Other types of arrow
2.10 Factorization systems

3 Functors

3.1
Functors
3.2 Actions
3.3 Types of functors
3.4 Equivalences
3.5 Quotient categories

4 Diagrams, naturality and sketches

4.1 Diagrams
4.2 Natural transformations
4.3 Natural transformations between functors
4.4 The Godement calculus of natural transformations
4.5 The Yoneda Lemma and universal elements
Linear sketches (graphs with diagrams)
4.6
Linear sketches with constants: initial term models
4.7
2-categories
4.8

xi

1
1
3
8
11

15
15
20
23
27
32
35
40
47
53
58

65
65
74
80
84
88

93
93
101
109
117
121
127
133
140

vii

viii

Contents

5 Products and sums

Finite products
Sums

5.1 The product of two objects in a category
5.2 Notation for and properties of products
5.3
5.4
5.5 Natural numbers objects
5.6 Deduction systems as categories
5.7 Distributive categories

6 Cartesian closed categories

6.1 Cartesian closed categories
6.2 Properties of cartesian closed categories
6.3 Typed λ-calculus
6.4
6.5 Arrows vs. terms
6.6

λ-calculus to category and back

Fixed points in cartesian closed categories

7 Finite product sketches

Finite product sketches

7.1
7.2 The sketch for semigroups
7.3 Notation for FP sketches
7.4 Arrows between models of FP sketches
7.5 The theory of an FP sketch
7.6
7.7

Initial term models for FP sketches
Signatures and FP sketches

8 Finite discrete sketches

8.1
Sketches with sums
8.2 The sketch for ﬁelds
8.3 Term algebras for FD sketches

9 Limits and colimits

9.1 Equalizers
9.2 The general concept of limit
9.3 Pullbacks
9.4 Coequalizers
9.5 Cocones
9.6 More about sums
9.7 Uniﬁcation as coequalizer
9.8 Properties of factorization systems

153
153
157
168
178
182
186
188

195
195
202
208
210
212
215

219
220
225
231
234
237
239
245

251
251
254
257

265
265
268
273
277
280
285
289
294

10 More about sketches

10.1 Finite limit sketches
10.2 Initial term models of FL sketches
10.3 The theory of an FL sketch
10.4 General deﬁnition of sketch

11 The category of sketches

11.1 Homomorphisms of sketches
11.2 Parametrized data types as pushouts
11.3 The model category functor

12 Fibrations

12.1 Fibrations
12.2 The Grothendieck construction
12.3 An equivalence of categories
12.4 Wreath products

13 Adjoints

13.1 Free monoids
13.2 Adjoints
13.3 Further topics on adjoints
13.4 Locally cartesian closed categories

14 Algebras for endofunctors

14.1 Fixed points for a functor
14.2 Recursive categories
14.3 Triples
14.4 Factorizations of a triple
14.5 Scott domains

15 Toposes

15.1 Deﬁnition of topos
15.2 Properties of toposes
15.3 Is a two-element poset complete?
15.4 Presheaves
15.5 Sheaves
15.6 Fuzzy sets
15.7 External functors
15.8 The realizability topos

Contents

ix

299
299
304
307
309

313
313
315
320

327
327
332
338
341

347
347
350
356
360

363
363
368
372
374
376

383
384
387
391
393
395
400
403
408

x

Contents

16 Categories with monoidal structure

16.1 Closed monoidal categories
16.2 Properties of A −◦ C
16.3 ∗-autonomous categories
16.4 The Chu construction

Solutions to the exercises
Solutions for Chapter 1
Solutions for Chapter 2
Solutions for Chapter 3
Solutions for Chapter 4
Solutions for Chapter 5
Solutions for Chapter 6
Solutions for Chapter 7
Solutions for Chapter 8
Solutions for Chapter 9
Solutions for Chapter 10
Solutions for Chapter 11
Solutions for Chapter 12
Solutions for Chapter 13
Solutions for Chapter 14
Solutions for Chapter 15
Solutions for Chapter 16

Bibliography

Index

413
413
417
422
424

431
431
433
442
449
460
467
471
475
477
488
489
491
494
498
506
510

517

531

Preface

This book is a textbook in basic category theory, written speciﬁcally to be
read by researchers and students in computing science. We expound the con-
structions we feel are basic to category theory in the context of examples and
applications to computing science. Some categorical ideas and constructions
are already used heavily in computing science and we describe many of these
uses. Other ideas, in particular the concept of adjoint, have not appeared as
widely in the computing science literature. We give here an elementary ex-
position of those ideas we believe to be basic categorical tools, with pointers
to possible applications when we are aware of them.

In addition, this text advocates a speciﬁc idea: the use of sketches as a
systematic way to turn ﬁnite descriptions into mathematical objects. This
aspect of the book gives it a particular point of view. We have, however,
taken pains to keep most of the material on sketches in separate sections. It
is not necessary to read to learn most of the topics covered by the book.

As a way of showing how you can use categorical constructions in the
context of computing science, we describe several examples of modeling lin-
guistic or computational phenomena categorically. These are not intended
as the ﬁnal word on how categories should be used in computing science;
indeed, they hardly constitute the initial word on how to do that! We are
mathematicians, and it is for those in computing science, not us, to deter-
mine which is the best model for a given application.

The emphasis in this book is on understanding the concepts we have
introduced, rather than on giving formal proofs of the theorems. We in-
clude proofs of theorems only if they are enlightening in their own right. We
have attempted to point the reader to the literature for proofs and further
development for each topic.

In line with our emphasis on understanding, we frequently recommend
one or another way of thinking about a concept. It is typical of most of the
useful concepts in mathematics that there is more than one way of perceiv-
ing or understanding them. It is simply not true that everything about a
mathematical concept is contained in its deﬁnition. Of course it is true that
in some sense all the theorems are inherent in its deﬁnition, but not what
makes it useful to mathematicians or to scientists who use mathematics. We
believe that the more ways you have of perceiving an idea, the more likely
you are to recognize situations in your own work where the idea is useful.

xi

xii

Preface

We have acted on the belief just outlined with many sentences beginning
with phrases such as ‘This concept may be thought of as . . .’. We have been
warned that doing this may present diﬃculties for a nonmathematician who
has only just mastered one way of thinking about something, but we feel it
is part of learning about a mathematical topic to understand the contextual
associations it has for those who use it.

About categories

Categories originally arose in mathematics out of the need of a formalism to
describe the passage from one type of mathematical structure to another. A
category in this way represents a kind of mathematics, and may be described
as category as mathematical workspace.

A category is also a mathematical structure. As such, it is a common
generalization of both ordered sets and monoids (the latter are a simple
type of algebraic structure that include transition systems as examples),
and questions motivated by those topics often have interesting answers for
categories. This is category as mathematical structure.

A third point of view is emphasized in this book. A category can be seen
as a structure that formalizes a mathematician’s description of a type of
structure. This is the role of category as theory. Formal descriptions in
mathematical logic are traditionally given as formal languages with rules for
forming terms, axioms and equations. Algebraists long ago invented a for-
malism based on tuples, the method of signatures and equations, to describe
algebraic structures. In this book, we advocate categories in their role as for-
mal theories as being in many ways superior to the others just mentioned.
Continuing along the same path, we advocate sketches as ﬁnite speciﬁcations
for the theories.

Changes in the second and third editions

The second edition contained new examples and exercises, many new items
in the bibliography, and new sections or chapters on 2-categories, distribu-
tive categories, monoidal categories and ∗-autonomous categories. The third
edition contains some new examples and exercises as well as new material
on factorization, ﬁnal algebras and Chu objects. In contrast to the second
edition, this third edition contains in the printed text all the chapters as well
as answers to all the exercises.

Lists of errors and corrections to each of the three editions is available by
anonymous FTP from ftp.math.mcgill.ca/pub/barr, as well as by web
browser at http://www.cwru.edu/artsci/math/wells/pub/papers.html.

Preface

xiii

Topics

Chapter 1 contains preliminary material on graphs, sets and functions. The
reader who has taken a discrete mathematics course may wish to skip this
chapter. However, some ﬁne points concerning sets and functions are dis-
cussed that may be worth looking at.

Chapter 2 introduces categories and gives many examples. We also give
certain simple constructions on categories and describe elementary properties
of objects and arrows.

Chapter 3 introduces functors, which are the mappings that preserve
the structure of categories. We make certain constructions here that will be
needed in later chapters.

Chapter 4 deals with three related topics: diagrams, natural transfor-
mations and sketches. Probably the ﬁrst thing noncategorists notice about
category theory is the proliferation of diagrams: here we begin the heavy
use of diagrams in this book. We discuss representable functors, universal
objects and the Yoneda embedding, which are fundamental tools for the cat-
egorist. We also introduce 2-categories in this chapter, as well as a very weak
version of sketch called a linear sketch.

Chapter 5 introduces products and sums. This allows one to use cate-
gories, in their role as theories, to specify functions of several variables and
to specify alternatives. In programming languages these appear as record
structures and variant records.

Chapter 6 is an introduction to cartesian closed categories, which have
been a major source of interest to computer scientists because they are
equivalent in theoretical power to typed lambda calculus. In this chapter,
we outline brieﬂy the process of translating between typed lambda calcu-
lus and cartesian closed categories. Normally, in learning a new language,
one should plunge right in speaking it instead of translating. However, it
may be helpful for the suspicious reader to see that translation is possible.
We outline two translation processes in this book: the one mentioned here
and another in Chapter 7. Except for those two places, category theory is
everywhere presented in its own terms.

Chapter 7 introduces ﬁnite product sketches, which have the expressive
power of multisorted universal algebra. These sketches provide a formalism
for universal algebra that provide a natural deﬁnition of models in cate-
gories other than the category of sets, and being based on graphs, they also
incorporated multisortedness into the deﬁnition in an intrinsic way. In this
chapter, a method is given for translating between ﬁnite product sketches
and the formalism of signatures and equations used in traditional universal
algebra. More expressive types of sketches are described in Chapters 8, 10
and 11.

xiv

Preface

Chapter 8 introduces ﬁnite discrete sketches, which have more expressive
power than universal algebra, in that they allow one to express alternatives.
Chapter 9 introduces the general concepts of limit and colimit of which
the constructions in Chapter 5 were a special case. These are basic construc-
tions in category theory that allow the formation of equationally deﬁned
subtypes and quotients. We describe uniﬁcation in terms of coequalizers of
free models of a certain kind of theory (free theory).

Chapter 10 describes ﬁnite limite sketches, which are more powerful than
universal algebra in a diﬀerent way from the ﬁnite discrete sketches of Chap-
ter 8, allowing partial operations, but only those whose domain can be de-
scribed equationally. These sketches have somewhat more expressive power
than universal Horn theories. We also describe brieﬂy the most general types
of sketches.

Chapter 11 introduces mappings between sketches, which are applied to
the description of parametrized data types. In this chapter, sketches are also
shown to be institutions in the sense of Goguen and Burstall.

Chapter 12 describes ﬁbrations and the Grothendieck construction, which
have applications to programming language semantics. We also consider
wreath products, a type of ﬁbration which has been used in the study of
automata.

Chapter 13 discusses the concept of adjointness, which is one of the grand
unifying ideas of category theory. It is closely related to two other ideas:
representable functors and the Yoneda Lemma. Many of the constructions
in preceding chapters are examples of adjoints.

We discuss representable functors, universal objects and the Yoneda
Lemma in Chapter 4, but we have deliberately postponed adjoints until
we have several examples of them in applications. The concept of adjoint
appears diﬃcult and unmotivated if introduced too early. Nevertheless, with
some exceptions, Chapter 13 can be read after having ﬁnished Section 4.5.
(This is discussed in more detail in the introduction to Chapter 13.)

Chapter 14 contains a miscellany of topics centered around the idea of
the algebra for a functor. We use this to deﬁne ﬁxed points for a functor, to
introduce the notion of a triple (monad), and to develop the Smyth-Plotkin
technique for constructing Scott domains.

Chapter 15 introduces toposes. A topos is a kind of generalized set the-
ory in which the logic is intuitionistic instead of classical. Toposes (or com-
putable subcategories thereof) have often been thought the correct arena for
programming language semantics. Categories of fuzzy sets are recognized as
almost toposes, and modest sets, which are thought by many to be the best
semantic model of polymorphic lambda calculus, live in a speciﬁc topos.

Chapter 16 introduces monoidal categories, ∗-autonomous categories and

the Chu construction. The latter form a model of linear logic.

Preface

xv

Most sections have exercises which provide additional examples of the
concepts and pursue certain topics further. Many exercises can be solved
by carefully keeping track of the deﬁnitions of the terms involved. A few
exercises are harder and are marked with a dagger. Some of those so marked
require a certain amount of ingenuity (although we do not expect the reader
to agree in every case with our judgment on this!). Others require familiarity
with some particular type of mathematical structure. For example, although
we deﬁne monoids in the text, a problem asking for an example of a monoid
with certain behavior can be diﬃcult for someone who has never thought
about them before reading this book.

This third edition contains solutions to all the exercises. The solutions
to the easy exercises, especially in the early chapters, go into considerable
detail. The solutions to the harder exercises often omit routine veriﬁcations.

Other categorical literature

Nearly all of the topics in category theory in this book are developed further
in the authors’ monograph [Barr and Wells, 1985]. Indeed, the present text
could be used as an introduction to that monograph. Most of the topics,
except sketches, are also developed further in [Mac Lane, 1971], [McLarty,
1992], [Freyd and Scedrov, 1990] and [Borceux, 1994]. Other texts speciﬁcally
concerning applications to computing science include [Asperti and Longo,
1991], [Crole, 1994], [Gunter, 1992], [Manes and Arbib, 1986], [Pierce, 1991],
[Rydeheard and Burstall, 1988] and [Walters, 1991]. Various aspects of the
close relationship between logic and categories (in their role as theories) are
treated in [Makkai and Reyes, 1977], [Lambek and Scott, 1986], [Bell, 1988]
and [Ad´amek and Rosiˇcky, 1994]. Recent collections of papers in computer
science which have many applications of category theory are [Pitt et al.,
1986], [Pitt, Poign´e and Rydeheard, 1987], [Ehrig et al., 1988], [Main et al.,
1988], [Gray and Scedrov, 1989], [Pitt et al., 1989], [Pitt et al., 1991], [Four-
man, Johnstone and Pitts, 1992], [Seely, 1992], [Pitt, Rydeheard and John-
stone, 1995] and [Moggi and Rosolini, 1997]. The reader may ﬁnd useful the
discussions of the uses of category theory in computing science in [Goguen,
1991], [Fokkinga, 1992] and in the tutorials in [Pitt et al., 1986].

Since this is an expository text, we make no eﬀort to describe the history
of the concepts we introduce or to discover the earliest references to theorems
we state. In no case does our statement of a theorem constitute a claim that
the theorem is original with us. In the few cases where it is original, we have
announced the theorem in a separate research article.

We do give an extensive bibliography; however, the main criteria for
inclusion of a work in the bibliography are its utility and availability, not
the creation of a historical record.

xvi

Preface

Prerequisites

This text assumes some familiarity with abstract mathematical thinking, and
some speciﬁc knowledge of the basic language of mathematics and computing
science of the sort taught in an introductory discrete mathematics course.

Terminology

In most scientiﬁc disciplines, notation and terminology are standardized, of-
ten by an international nomenclature committee. (Would you recognize Ein-
stein’s equation if it said p = HU 2?) We must warn the nonmathematician
reader that such is not the case in mathematics. There is no standardization
body and terminology and notation are individual and often idiosyncratic.
We will introduce and stick to a ﬁxed notation in this book, but any reader
who looks in another source must expect to ﬁnd diﬀerent notation and even
diﬀerent names for the same concept – or what is worse, the same name used
for a diﬀerent concept. We have tried to give warnings when this happens,
with the terminology at least.

Acknowledgments for the ﬁrst edition

In the preparation of this book, the ﬁrst author was assisted by a grant
from the NSERC of Canada and the second by NSF grant CCR-8702425.
The authors would also like to thank McGill University and Case Western
Reserve University, respectively, for sabbatical leaves, and the University of
Pennsylvania for a very congenial setting in which to spend those leaves.

We learned much from discussions with Adam Barr, Robin Cockett,
George Ernst, Tony Hoare, Colin McLarty, Pribhakar Mateti, William F.
Ogden, Robert Par´e and John Power. Bob Harper, Tony Hoare and an anony-
mous referee made many helpful corrections and suggestions. We would espe-
cially like to thank Benjamin Pierce, who has read the book from beginning
to end and found scores of errors, typographical and otherwise.

Acknowledgments for the second edition

We are grateful to the many readers who reported errors and obscurities in
the ﬁrst edition. They include Nils Andersen, David Benson, Anthony Bucci,
Anders Gammelgaard, Stephen J. Bevan, Andrew Malton, Jean-Pierre Mar-
quis, Frank Piessens, Richard Rarick, Paul Taylor, Todd Turnidge, Nico
Verwer, Al Vilcius, Jodelle Wuertzer, and Han Yan. We are also grateful to
Barbara Beeton for help with fonts.

Michael Barr
Department of Mathematics

and Statistics
McGill University
805 Sherbrooke St. W.
Montr´eal, Qu´ebec
Canada H3P 1S4
barr@barrs.org

Preface

xvii

Charles Wells
Department of Mathematics
Case Western Reserve University
10900 Euclid Ave
Cleveland, OH 44106-7058
USA
charles@freude.com

1
Preliminaries

This chapter is concerned with some preliminary ideas needed for the intro-
duction to categories that begins in Chapter 2. The main topics are (i) an
introduction to our notation and terminology for sets and functions and a
discussion of some ﬁne points that can cause trouble if not addressed early,
and (ii) a discussion of graphs, by which we mean a speciﬁc type of directed
graph. Graphs are a basis for the deﬁnition of category and an essential part
of the deﬁnition of both commutative diagrams and sketches.

1.1 Sets

The concept of set is usually taken as known in mathematics. Instead of
attempting a deﬁnition, we will give a speciﬁcation for sets and another one
for functions that is adequate for our purposes.

1.1.1 Speciﬁcation A set is a mathematical entity that is distinct from,
but completely determined by, its elements (if any). For every entity x and
set S, the statement x ∈ S, read ‘x is an element of S’, is a sentence that is
either true or false.

A ﬁnite set can be deﬁned by listing its elements within braces; for exam-
ple, {1, 3, 5} is a set completely determined by the fact that its only elements
are the numbers 1, 3 and 5. In particular, the set { } with no elements is
called the empty set and is denoted ∅.

The setbuilder notation deﬁnes a set as the collection of entities that
satisfy a predicate; if x is a variable ranging over a speciﬁc type of data and
P (x) is a predicate about that type of data, then the notation {x | P (x)}
denotes the set of all things that have the same type as x about which P (x)
is true. Thus, if x is a variable of type real, {x | x > 7} is the set of real
numbers greater than 7. The set {x | P (x)} is called the extension of the
predicate P .

1.1.2 Notation We denote the set of natural numbers (nonnegative inte-
gers) by N, the set of all integers by Z, the set of all rational numbers by Q,
and the set of all real numbers by R.

1

2

Preliminaries

1.1.3 Russell’s paradox The setbuilder notation (which implicitly sup-
poses that every predicate determines a set) has a bug occasioned by Rus-
sell’s paradox, which uses setbuilder notation to deﬁne something that
cannot be a set:

{S | S is a set and S /∈ S}

This purports to be the set of all those sets that are not elements of them-
selves. If this were indeed a set T , then T ∈ T implies by deﬁnition that
T /∈ T , whereas T /∈ T implies by deﬁnition that T ∈ T . This contradiction
shows that there is no such set T .

A simple way to avoid this paradox is to restrict x to range over a partic-
ular type of data (such as one of the various number systems – real, integers,
etc.) that already forms a set. This prophylaxis guarantees safe sets.

If you ﬁnd it diﬃcult to comprehend how a set could be an element of itself,
rest assured that most approaches to set theory rule that out. (But see [Devlin,
1993].) Following those approaches, the (impossible) set T consists of all sets,
so that we now know that there is no set whose elements are all the sets that
exist – there is no ‘set of all sets’.

1.1.4 Deﬁnition If S and T are sets, the cartesian product of S and T
is the set S ×T of ordered pairs (s, t) with s ∈ S and t ∈ T . Thus in setbuilder
notation, S × T = {(s, t) | s ∈ S and t ∈ T }. Observe that T × S = {(t, s) |
s ∈ S and t ∈ T }, and so is not the same set as S × T unless S = T .

The ordered pair (s, t) is determined uniquely by the fact that its ﬁrst co-
ordinate is s and its second coordinate is t. That is essentially a speciﬁcation
of ordered pairs. The formal categorical deﬁnition of product in Section 5.1
is based on this.

More generally, an ordered n-tuple is a sequence (a1, . . . , an) deter-
mined uniquely by the fact that for i = 1, . . . , n, the ith coordinate of
(a1, . . . , an) is ai. Then the cartesian product S1 × S2 × · · · × Sn is the set of
all n-tuples (a1, . . . , an) with ai ∈ Si for i = 1, . . . , n.

1.1.5 Deﬁnition A relation α from a set S to a set T is a subset of
S × T . Any such subset is a relation from S to T .

Extreme examples of relations from S to T are the empty set and the set
S × T . Another useful example is the diagonal relation ∆S (often written
simply ∆) from S to S for any set S; by deﬁnition,

∆S = {(x, x) | x ∈ S}

The usual order relations such as ‘<’ and ‘≤’ on R (and other sets of num-
bers) are examples of relations; thus ‘<’ in this sense is the set

{(r, s) | There is a positive number t such that r + t = s}

1.2 Functions

3

As this last example illustrates, if α is a relation from S to T , then we write
s α t to mean that (s, t) ∈ α. However, the usual symbol for ∆ is of course
‘=’.

Observe that if S (cid:54)= T , then a relation from S to T is not the same thing

as a relation from T to S (because then S × T (cid:54)= T × S).

1.2 Functions

1.2.1 Speciﬁcation A function f is a mathematical entity with the fol-
lowing properties:

F–1 f has a domain and a codomain, each of which must be a set.
F–2 For every element x of the domain, f has a value at x, which is an

element of the codomain and is denoted f (x).

F–3 The domain, the codomain, and the value f (x) for each x in the domain

are all determined completely by the function.

F–4 Conversely, the data consisting of the domain, the codomain, and the
value f (x) for each element x of the domain completely determine the
function f .

The domain and codomain are often called the source and target of f ,

respectively.

The notation f : S −→ T is a succinct way of saying that the function f
has domain S and codomain T . It is used both as a verb, as in ‘Let f : S
−→ T ’, which would be read as ‘Let f be a function from S to T ’, and as a
noun, as in ‘Any function f : S −→ T satisﬁes . . .’, in which the expression
would be read as ‘f from S to T ’. One also says that f is of type ‘S arrow
T ’.

We will use the barred arrow notation to provide an anonymous no-
tation for functions. For example, the function from R to R that squares its
input can be denoted x (cid:55)→ x2 : R −→ R. The barred arrow goes from input
datum to output datum and the straight arrow goes from domain to codo-
main. The barred arrow notation serves the same purpose as the logicians’
lambda notation, λx.x2, which we do not use except in the discussion of λ-
calculus in Chapter 6. The barred arrow notation, like the lambda notation,
is used mainly for functions deﬁned by a formula.

1.2.2 The signiﬁcance of F–3 is that a function is not merely a rule, but
a rule together with its domain and codomain. This is the point of view
taken by category theorists concerning functions, but is not shared by all
mathematicians. Thus category theorists insist on a very strong form of
typing. For example, these functions

4

Preliminaries

(i) x (cid:55)→ x2 : R −→ R+
(ii) x (cid:55)→ x2 : R −→ R
(iii) x (cid:55)→ x2 : R+ −→ R+
(iv) x (cid:55)→ x2 : R+ −→ R

(where R+ is the set of nonnegative reals) are four diﬀerent functions. This
distinction is not normally made in college mathematics courses, and indeed
there is no reason to make the distinction there, but it turns out to be
necessary to make it in category theory and some other branches of abstract
mathematics.

It can be useful to make the distinction even at an elementary level.
For example, every set S has an identity function idS : S −→ S for which
idS(x) = x for all x ∈ S. If S is a subset of a set T , then there is an inclusion
function i : S −→ T for which i(x) = x for all x ∈ S. The functions idS and
i are diﬀerent functions because they have diﬀerent codomains, even though
their value at each element of their (common) domain is the same.

1.2.3 Deﬁnition The graph of a function f : S −→ T is the set of or-
dered pairs: {(x, f (x)) | x ∈ S}.

Thus the graph of a function from S to T is a relation from S to T as
deﬁned in Deﬁnition 1.1.5. However, not any relation will do; it must have
the functional property that for all s ∈ S, there is one and only one t ∈ T
such that (s, t) is in the graph.

Many texts, but not this one, deﬁne a function to be a relation with the
functional property. That deﬁnition is not equivalent to Deﬁnition 1.2.3; a
relation from S to T with the functional property determines S (it is the set
of all ﬁrst coordinates of ordered pairs of the relation) but not T , so that a
function deﬁned in that way does not determine its codomain. Some writers
who deﬁne a function to be a relation with the functional property use the
word mapping for what we call a function (where the domain and codomain
are part of the deﬁnition). In this book (as in most books) we use the word
“mapping” or “map” synonymously with “function”.

1.2.4 Deﬁnition The image of a function (also called its range) is its
set of values; that is, the image of f : S −→ T is {t ∈ T | ∃s ∈ S for which
f (s) = t}. The image of each of the squaring functions mentioned in 1.2.2 is
of course the set of nonnegative reals.

The metaphor behind the names “map” and “image” reveals a way of thinking
that is basic in modern mathematics: A function f : S −→ T is thought of as
a map in the space T (in the sense of cartography) of its domain S. Thus a
map of New York City (= S) is a collection of symbols on a piece T of paper
together with the (partially implicit) information about which points on the

1.2 Functions

5

paper T correspond to actual locations in the city S; this is the function that
takes a point in the city to a point on the sheet of paper. The image is the set
of symbols and their arrangement on the page, forgetting what in the city they
correspond to.

The fact that the locations on the paper correspond to the locations in the city
comes from the fact that the map is (approximately) shape-preserving. Most
functions actually used in mathematics preserve some kind of structure.

1.2.5 Deﬁnition A function f : S −→ T is injective if whenever s (cid:54)= s(cid:48)
in S, then f (s) (cid:54)= f (s(cid:48)) in T .

Another name for injective is one to one. The identity and inclusion
functions described previously are injective. The function x (cid:55)→ x2 : R −→ R
is not injective since it takes 2 and −2 to the same value, namely 4. On the
other hand, x (cid:55)→ x3 is injective.

There is a unique function e : ∅ −→ T for any set T . It has no values. It

is vacuously injective.

Do not confuse the deﬁnition of injective with the property that all functions
have that if s = s(cid:48) then f (s) = f (s(cid:48)). Another way of saying that a function is
injective is via the contrapositive of the deﬁnition of injective: if f (s) = f (s(cid:48)),
then s = s(cid:48).

1.2.6 Deﬁnition A function f : S −→ T is surjective if its image is T .

The identity function on a set is surjective, but no other inclusion function

is surjective.

Observe that the deﬁnition of surjective depends on the speciﬁed codo-
main; for example, of the four squaring functions listed in 1.2.2, only (i) and
(iii) are surjective. A surjective function is often said to be onto.

A function is bijective if it is injective and surjective. A bijective function

is also called a one to one correspondence.

1.2.7 Functions and cartesian products
If S and T are sets, the carte-
sian product S × T is equipped with two coordinate or projection func-
tions proj1 : S ×T −→ S and proj2 : S ×T −→ T . The coordinate functions are
surjective if S and T are both nonempty. Coordinate functions for products
of more than two sets are deﬁned analogously.

There are two additional notational devices connected with the cartesian

product.

1.2.8 Deﬁnition If X, S and T are sets and f : X −→ S and g : X −→ T
are functions, then the function (cid:104)f, g(cid:105) : X −→ S × T is deﬁned by (cid:104)f, g(cid:105)(x) =
(f (x), g(x)) for all x ∈ X.

6

Preliminaries

1.2.9 Deﬁnition If X, Y , S and T are sets and f : X −→ S, g : Y −→ T
are functions, then f × g : X × Y −→ S × T is the function deﬁned by (f ×
g)(x, y) = (f (x), g(y)). It is called the cartesian product of the functions
f and g.

These functions are discussed further in Chapter 5.

1.2.10 Deﬁnition If f : S −→ T and g : T −→ U , then the composite
function g ◦ f : S −→ U is deﬁned to be the unique function with domain
S and codomain U for which (g ◦ f )(x) = g(f (x)) for all x ∈ S. In the
computing science literature, f ; g is often used for g ◦ f .

Category theory is based on composition as a fundamental operation in
much the same way that classical set theory is based on the ‘element of’ or
membership relation.

In categorical treatments, it is necessary to insist, as we have here, that
the codomain of f be the domain of g for the composite g ◦ f to be deﬁned.
Many texts in some other branches of mathematics require only that the
image of f be included in the domain of g.

1.2.11 Deﬁnition If f : S −→ T and A ⊆ S, then the restriction of f to
A is the composite f ◦ i, where i : A −→ S is the inclusion function. Thus
the squaring function in 1.2.2(iii) is the restriction to R+ of the squaring
function in 1.2.2(i).

Similarly, if T ⊆ B, f is called the corestriction of the function j ◦ f : S
−→ B to T , where j is the inclusion of T in B. Thus, in 1.2.2, the function
in (i) is the corestriction to R+ of the function in (ii).

1.2.12 Functions in theory and practice The concept of function can
be explicitly deﬁned in terms of its domain, codomain and graph. Precisely,
a function f : S −→ T could be deﬁned as an ordered triple (S, Γ, T ) with the
property that Γ is a subset of the cartesian product S × T with the functional
property (Γ is the graph of f ). Then for x ∈ S, f (x) is the unique element y ∈
T for which (x, y) ∈ Γ. Such a deﬁnition clearly satisﬁes speciﬁcation 1.2.1.
The description of functions in 1.2.1 is closer to the way a mathemati-
cian thinks of a function than the deﬁnition in 1.2.12. For a mathematician,
a function has a domain and a codomain, and if x is in the domain, then
there is a well deﬁned value f (x) in the codomain. It is wrong to think that a
function is actually an ordered triple as described in the preceding paragraph
in the same sense that it is wrong for a programmer writing in a high level
language to think of the numbers he deals with as being expressed in binary
notation. The possible deﬁnition of function in the preceding paragraph is an
implementation of the speciﬁcation for function, and just as with program

1.2 Functions

7

speciﬁcations the expectation is that one normally works with the speciﬁ-
cation, not the implementation, in mind. We make a similar point in 5.1.1
when we discuss ordered pairs in the context of categorical products.

In understanding the diﬀerence between a speciﬁcation of something and an
implementation of it, it may be instructive to read the discussion of this point
in [Halmos, 1960], Section 6, who gives the deﬁnition of an ordered pair. The
usual deﬁnition is rather unnatural and serves only to demonstrate that a
construction with the required property exists. Speciﬁcations are also discussed
in [Wells, 1995].

1.2.13 Deﬁnition Let S and T be sets, and let Hom(S, T ) denote the set
of all functions with domain S and codomain T . (This ﬁts with the standard
notation we introduce in Chapter 2.) Let f : T −→ V be a function. The
function

Hom(S, f ) : Hom(S, T ) −→ Hom(S, V )

is deﬁned by

Hom(S, f )(g) = f ◦ g

Hom(S, f ) is an example of a hom function. Note that Hom(S, x) is over-
loaded notation: when x is a set, Hom(S, x) is a set of functions, but when
x is a function, so is Hom(S, x).

As an example of how one works with Hom functions, we show that if S
is not the empty set, then f is injective if and only if Hom(S, f ) is injective.
Suppose f is injective and that Hom(S, f )(g) = Hom(S, f )(h). Then f ◦
g = f ◦ h. Let x be any element of S. Then f (g(x)) = f (h(x)) and f is
injective, so g(x) = h(x). Since x is arbitrary, g = h. Conversely, suppose
f is not injective. Then for some t, u ∈ T with t (cid:54)= u, f (t) = f (u). Deﬁne
functions g : S −→ T and h : S −→ T to be the constant functions with values
t and u respectively. Because S is nonempty, g (cid:54)= h. For any x ∈ S, f (g(x)) =
f (t) = f (u) = f (h(x)), so

Hom(S, f )(g) = f ◦ g = f ◦ h = Hom(S, f )(h)

Hence Hom(S, f ) is not injective.

1.2.14 Exercises

Most introductory texts in discrete mathematics provide dozens of exercises
concerning sets, functions and their properties, and operations such as union,
intersection, and so on. We regard our discussion as establishing notation, not
as providing a detailed introduction to these concepts, and so do not give such
exercises here. The exercises we do provide here allow a preliminary look at
some categorical constructions that will appear in detail later in the book.

8

Preliminaries

1. In the notation of 1.2.13, let h : W −→ S be a function and deﬁne a
function Hom(h, T ) : Hom(S, T ) −→ Hom(W, T ) by Hom(h, T )(g) = g ◦ h.
Show that if T has at least two elements, then h is surjective if and only if
Hom(h, T ) is injective.

2. a. Using the notation of 1.2.13, show that the mapping that takes a pair
(f : X −→ S, g : X −→ T ) of functions to the function (cid:104)f, g(cid:105) : X −→ S × T
deﬁned in Deﬁnition 1.2.8 is a bijection from Hom(X, S) × Hom(X, T ) to
Hom(X, S × T ).

b. If you set X = S × T in (a), what does idS×T correspond to under the

bijection?

3. Let S and T be two disjoint sets, and let V be a set.

a. Let φ : Hom(S, V ) × Hom(T, V ) −→ Hom(S ∪ T, V ) be the mapping
that takes a pair (f : S −→ V, g : T −→ V ) to the function (cid:104)f |g(cid:105) : S ∪ T −→ V
deﬁned by

(cid:104)f |g(cid:105)(x) =

(cid:189)

f (x)
g(x)

if x ∈ S
if x ∈ T

Show that φ is a bijection.

b. If you set V = S ∪ T in (a), what is φ(idS∪T )?

4. If P(C) denotes the power set (set of all subsets) of C, then Rel(A, B) =
P(A × B) denotes the set of relations from A to B. Let φ : Rel(A, B) −→
Hom(A, PB) be deﬁned by

φ(α)(a) = {b ∈ B | (a, b) ∈ α}

a. Show that φ is a bijection.
b. Let A = B. What corresponds to ∆A under this bijection?
c. If we let A = PB then φ−1 : Hom(PB, PB) −→ Rel(PB, B). What

is φ−1(idPB)?

1.3 Graphs

The type of graph that we discuss in this section is a speciﬁc version of
directed graph, one that is well adapted to category theory, namely what
is often called a directed multigraph with loops. A graph is a constituent
of a sketch, which we introduce in Chapter 4, and is an essential ingredient
in the deﬁnition of commutative diagram, which is the categorist’s way of
expressing equations. The concept of graph is also a precursor to the concept
of category itself: a category is, roughly speaking, a graph in which paths
can be composed.

1.3 Graphs

9

1.3.1 Deﬁnition and notation Formally, to specify a graph, you must
specify its nodes (or objects) and its arrows. Each arrow must have a
speciﬁc source (or domain) node and target (or codomain) node. The
notation ‘f : a −→ b’ means that f is an arrow and a and b are its source and
target, respectively. If the graph is small enough, it may be drawn with its
nodes indicated by dots or labels and each arrow by an actual arrow drawn
from its source to its target.

There may be one or more arrows – or none at all – with given nodes as
source and target. Moreover, the source and target of a given arrow need not
be distinct. An arrow with the same source and target node will be called
an endoarrow or endomorphism of that node.

We will systematically denote the collection of nodes of a graph G by G0
and the collection of arrows by G1, and similarly with other letters (H has
nodes H0, C has nodes C0, and so on). The nodes form the zero-dimensional
part of the graph and the arrows the one-dimensional part.

1.3.2 Example Let G0 = {1, 2}, G1 = {a, b, c},

source(a) = target(a) = source(b) = target(c) = 1

and

Then we can represent G as

target(b) = source(c) = 2

(cid:82)

a

(cid:190)

1

(cid:45)b
c

2

(1.1)

1.3.3 Example The graph of sets and functions has all sets as nodes
and all functions between sets as arrows. The source of a function is its
domain, and its target is its codomain.

In this example, unlike the previous ones, the nodes do not form a set.
(See 1.1.3.) This fact will not cause trouble in reading this book, and will
not usually cause trouble in applications. We use some standard terminology
for this distinction.

1.3.4 Deﬁnition A graph that has a set of nodes and arrows is a small
graph; otherwise, it is a large graph.

Thus the graph of sets and functions is a large graph. More generally we
refer to any kind of mathematical structure as ‘small’ if the collection(s) it
is built on form sets, and ‘large’ otherwise.

Note that if G is a small graph, source : G1 −→ G0 and target : G1 −→ G0

are functions.

10

Preliminaries

1.3.5 Deﬁnition A graph is called discrete if it has no arrows.

In particular, the empty graph, with no nodes and no arrows, is discrete.
A small discrete graph is essentially a set; small discrete graphs and sets are
usefully regarded as the same thing for most purposes.

1.3.6 Deﬁnition A graph is ﬁnite if the number of nodes and arrows is
ﬁnite.

1.3.7 Example It is often convenient to picture a relation on a set as a
graph. For example, let A = {1, 2, 3}, B = {2, 3, 4} and

α = {(1, 2), (2, 2), (2, 3), (1, 4)}

Then α can be pictured as

(cid:82)
2(cid:45)

3(cid:45)

1

(cid:63)
4

(1.2)

Of course, graphs that arise this way never have more than one arrow

with the same source and target. Such graphs are called simple graphs.

Note that the graph of a function, as deﬁned in 1.2.1, is a relation
(see 1.1.5), and so corresponds to a graph in the sense just described. The
resulting picture has an arrow from each element x of the domain to f (x)
so it is not the graph of the function in the sense used in calculus.

Sometimes one can represent a data structure by a graph.
1.3.8 Example
This graph represents the set N of natural numbers in terms of zero and the
successor function (adding 1):

succ

n(cid:45)0 (cid:82)

1

(1.3)

The name ‘1’ for the left node is the conventional notation to require that
the node denote a singleton set, that is, a set with exactly one element.
In 4.7.6 we provide a formal mathematical meaning to the idea that this
graph generates the natural numbers. Right now, this is just a graph with
nodes named ‘1’ and ‘n’.

This informal idea of a graph representing a data type will become the

basis of the formal theory of sketches in Chapter 4.

1.3.9 Example In the same spirit as Example 1.3.8, let us see what data
type is represented by the graph

1.4 Homomorphisms of graphs

11

a

s
−→−→
t

n

(1.4)

The data type has a signature consisting of two objects, call them a and
n, and two arrows, let us call them (temporarily) s, t : a −→ n. But if we
interpret a as arrows, n as nodes and s and t as source and target, this is
exactly what we have deﬁned a small graph to be: two sets and two functions
from one of the sets to the other. For this reason, this graph is called the
graph of graphs. (See [Lawvere, 1989].)

1.3.10 Exercises

1. The graphs in this section have labeled nodes; for example, the two nodes
in (1.3) are labeled ‘1’ and ‘n’. Produce a graph analogous to (1.4) that
expresses the concept of ‘graph with nodes labeled from a set L’.

2. Let G be a graph with set of nodes N and set of arrows A. Show that G is
simple if and only if the function (cid:104)source, target(cid:105) : A −→ N × N is injective.
(This uses the pair notation for functions to products as described in 1.2.8.)

1.4 Homomorphisms of graphs

A homomorphism of graphs should preserve the abstract shape of the graph.
A reasonable translation of this vague requirement into a precise mathemat-
ical deﬁnition is as follows.

1.4.1 Deﬁnition A homomorphism φ from a graph G to a graph H ,
denoted φ : G −→ H , is a pair of functions φ0 : G0 −→ H0 and φ1 : G1 −→ H1
with the property that if u : m −→ n is an arrow of G , then φ1(u) : φ0(m)
−→ φ0(n) in H .

It is instructive to restate this deﬁnition using the source and target
mappings from 1.3.9: let sourceG : G1 −→ G0 be the source map that takes
an arrow (element of G1) to its source, and similarly deﬁne targetG , sourceH
and targetH . Then the pair of maps φ0 : G0 −→ H0 and φ1 : G1 −→ H1 is a
graph homomorphism if and only if

and

sourceH ◦ φ1 = φ0 ◦ sourceG

targetH ◦ φ1 = φ0 ◦ targetG

12

Preliminaries

1.4.2 Notation of the form a : B −→ C is overloaded in several ways. It
can denote a set-theoretic function, a graph homomorphism or an arrow in
a graph. In fact, all three are instances of the third since there is a large
graph whose nodes are sets and arrows are functions (see 1.3.3) and another
whose nodes are (small) graphs and arrows are graph homomorphisms.

Another form of overloading is that if φ : G −→ H is a graph homo-
morphism, φ actually stands for a pair of functions we here call φ0 : G0
−→ H0 and φ1 : G1 −→ H1. In fact, it is customary to omit the subscripts
and use φ for all three (the graph homomorphism as well as its components
φ0 and φ1).

This does not lead to ambiguity in practice; in reading about graphs you
are nearly always aware of whether the author is talking about nodes or
arrows. We will keep the subscripts in this section and drop them thereafter.

If G is any graph, the identity homomorphism idG : G
1.4.3 Example
−→ G is deﬁned by (idG )0 = idG0 (the identity function on the set of nodes
of G ) and (idG )1 = idG1.

1.4.4 Example If G is the graph

and H is this graph,

(cid:82)
2(cid:45)

3(cid:45)

1

(cid:63)
4

(cid:82)
F(cid:45)

(cid:73)

S

(cid:63)
Q

(1.5)

(1.6)

then there is a homomorphism φ : G −→ H for which φ0(1) = S, φ0(2) =
φ0(3) = F and φ0(4) = Q, and φ1 takes the loop on 2 and the arrow from
2 to 3 both to the upper loop on F ; what φ1 does to the other two arrows
is forced by the deﬁnition of homomorphism. Because there are two loops
on F there are actually four possibilities for φ1 on arrows (while keeping φ0
ﬁxed).

1.4 Homomorphisms of graphs

13

1.4.5 Example If H is any graph with a node n and a loop u : n −→ n,
then there is a homomorphism from any graph G to H that takes every
node of G to n and every arrow to u. This construction gives two other
homomorphisms from G to H in Example 1.4.4 besides the four mentioned
there. (There are still others.)

1.4.6 Example There is a homomorphism σ from Example 1.3.8 to the
graph of sets that takes the node called 1 to a one-element set, which in
contexts like this we will denote {∗}, and that takes the node n to the set N
of natural numbers. (Following the practice in computing science rather
than mathematics, we start our natural numbers at 0.) The homomorphism
σ takes the arrow 1 −→ n to the function ∗ (cid:55)→ 0 that picks out the natural
number 0, and σ(succ), naturally, is the function that adds 1. This is an ex-
ample of a model of a sketch, which we discuss in 4.7.7. This homomorphism
gives a semantics for the sketch constituted by the abstract graph of 1.3.8.

1.4.7 Example The homomorphism in Example 1.4.6 is not the only homo-
morphism from Example 1.3.8 to sets. One can let n go to the set of integers
(mod k) for a ﬁxed k and let succ be the function that adds one (mod k) (it
wraps around). You can also get other homomorphisms by taking this ex-
ample (or 1.4.6) and adjoining some extra elements to the set corresponding
to n which are their own successors.

1.4.8 Example Example 1.3.9 can be given a semantics in the same way
as Example 1.3.8. If G is any small graph, there is a graph homomorphism
φ from the diagram in (1.4) to the graph of sets for which φ0(n) is the set
of nodes of G , φ0(a) is the set of arrows, and φ1 takes the arrows labeled
source and target to the corresponding functions from the set of arrows of
G to the set of nodes of G .

Moreover, the converse is true: any homomorphism from (1.4) to the
graph of sets gives a graph. The nodes of the graph are the elements of φ0(n)
and the arrows are the elements of φ0(a). If f ∈ φ0(a), then the source of f
is φ1(source)(f ) and the target is φ1(target)(f ). Thus the graph of Exam-
ple 1.3.2 corresponds to the homomorphism φ where φ0(n) = {1, 2}, φ0(a) =
{a, b, c}, φ1(source) is the function a (cid:55)→ 1, b (cid:55)→ 1, c (cid:55)→ 2 and φ1(target) is the
function a (cid:55)→ 1, b (cid:55)→ 2, c (cid:55)→ 1.

In short, graph homomorphisms from (1.4) to the graph of sets corre-

spond to what we normally call graphs.

1.4.9 Notation In an expression like ‘φ1(source)(f )’, φ1 is a function whose
value at ‘source’ is a function that applies to an arrow f . As this illustrates,
the application operation associates to the left.

14

Preliminaries

1.4.10 Exercises

1. Show that if the codomain H of a graph homomorphism φ is a simple
graph, then φ1 is determined uniquely by φ0.

2. Show that the composite of graph homomorphisms is a graph homo-
morphism. Precisely: if φ : G −→ H and ψ : H −→ K are graph homo-
morphisms, then deﬁne the composite ψ ◦ φ by requiring that (ψ ◦ φ)0 =
ψ0 ◦ φ0 and (ψ ◦ φ)1 = ψ1 ◦ φ1. Then prove that ψ ◦ φ is a graph homo-
morphism.

3. Let φ be a homomorphism G −→ H for which both φ0 and φ1 are bijective.
Deﬁne ψ : H −→ G by ψ0 = (φ0)−1 and ψ1 = (φ1)−1.

a. Show that ψ is a graph homomorphism from H to G .
b. Using the deﬁnition of composite in the preceding exercise, show that

both ψ ◦ φ = idG and φ ◦ ψ = idH .

2
Categories

A category is a graph with a rule for composing arrows head to tail to give
another arrow. This rule is subject to certain conditions, which we will give
precisely in Section 2.1. The connection between functional programming
languages and categories is described in Section 2.2. Some special types of
categories are given in Section 2.3. Sections 2.4 and 2.5 are devoted to a
class of examples of the kind that originally motivated category theory. The
reader may wish to read through these examples rapidly rather than trying
to understand every detail.

Constructions that can be made with categories are described in Sec-
tion 2.6. Sections 2.7, 2.8 and 2.9 describe certain properties that an arrow
of a category may have. Section 2.10 describes factorization systems, which
are useful structures in many categories. This section is used only in Chap-
ters 9 and 16.

2.1 Basic deﬁnitions

Before we deﬁne categories, we need a preliminary deﬁnition.

2.1.1 Deﬁnition Let k > 0. In a graph G , a path from a node x to a
node y of length k is a sequence (f1, f2, . . . , fk) of (not necessarily distinct)
arrows for which

(i) source(fk) = x,
(ii) target(fi) = source(fi−1) for i = 2, . . . , k, and
(iii) target(f1) = y.

By convention, for each node x there is a unique path of length 0 from x to
x that is denoted (). It is called the empty path at x.

Observe that if you draw a path as follows:

fk−−→ ·

fk−1−−−−→ · · ·

·

f2−−→ ·

f1−−→ ·

with the arrows going from left to right, fk will be on the left and the
subscripts will go down from left to right. We do it this way for consistency
with composition (compare 2.1.3, C–1).

15

16

Categories

For any arrow f , (f ) is a path of length 1. As an example, in Diagram (1.3)
on page 10, there is just one path of each length k from n to n, namely (),
(succ), (succ, succ), and so on.

2.1.2 Deﬁnition The set of paths of length k in a graph G is denoted Gk.
In particular, G2, which will be used in the deﬁnition of category, is the
set of pairs of arrows (g, f ) for which the target of f is the source of g. These
are called composable pairs of arrows.

We have now assigned two meanings to G0 and G1. This will cause no conﬂict
as G1 refers indiﬀerently either to the collection of arrows of G or to the
collection of paths of length 1, which is essentially the same thing. Similarly,
we use G0 to represent either the collection of nodes of G or the collection of
empty paths, of which there is one for each node. In each case we are using
the same name for two collections that are not the same but are in a natural
one to one correspondence. Compare the use of ‘2’ to denote either the integer
or the real number. As this last remark suggests, one might want to keep the
two meanings of G1 separate for purposes of implementing a graph as a data
structure.

The one to one correspondences mentioned in the preceding paragraph were
called ‘natural’. The word is used informally here, but in fact these correspon-
dences are natural in the technical sense (Exercise 10 of Section 4.3).

2.1.3 Categories A category is a graph C together with two functions
c : C2 −→ C1 and u : C0 −→ C1 with properties C–1 through C–4 below.
(Recall that C2 is the set of paths of length 2.) The elements of C0 are
called objects and those of C1 are called arrows. The function c is called
composition, and if (g, f ) is a composable pair, c(g, f ) is written g ◦ f and
is called the composite of g and f . If A is an object of C , u(A) is denoted
idA, which is called the identity of the object A.

C–1 The source of g ◦ f is the source of f and the target of g ◦ f is the

target of g.

C–2 (h ◦ g) ◦ f = h ◦ (g ◦ f ) whenever either side is deﬁned.
C–3 The source and target of idA are both A.
C–4 If f : A −→ B, then f ◦ idA = idB ◦ f = f .

The signiﬁcance of the fact that the composite c is deﬁned on G2 is that
g ◦ f is deﬁned if and only if the source of g is the target of f . This means that
composition is a function whose domain is an equationally deﬁned subset of
G1 × G1: the equation requires that the source of g equal the target of f . It
follows from this and C–1 that in C–2, one side of the equation is deﬁned if
and only if the other side is deﬁned.

In the category theory literature, idA is often written just A.

2.1 Basic deﬁnitions

17

2.1.4 Terminology In much of the categorical literature, ‘morphism’, ‘do-
main’ and ‘codomain’ are more common than ‘arrow’, ‘source’ and ‘target’.
In this book we usually use the language we have just introduced of ‘arrow’,
‘source’ and ‘target’. We will normally denote objects of categories by capital
letters but nodes of graphs (except when we think of a category as a graph)
by lower case letters. Arrows are always lower case.

In the computing science literature, the composite g ◦ f is sometimes
written f ; g, a notation suggested by the perception of a typed functional
programming language as a category (see 2.2.1).

We have presented the concept of category as a two-sorted data structure;
the sorts are the objects and the arrows. Categories are sometimes presented
as one-sorted – arrows only. The objects can be recovered from the fact that
C–3 and C–4 together characterize idA (Exercise 4), so that there is a one
to one correspondence between the objects and the identity arrows idA.

2.1.5 Deﬁnition A category is small if its objects and arrows constitute
sets; otherwise it is large (see the discussion of Russell’s paradox, 1.1.3).

The category of sets and functions deﬁned in 2.1.11 below is an example
of a large category. Although one must in principle be wary in dealing with
large classes, it is not in practice a problem; category theorists have rarely,
if ever, run into set-theoretic diﬃculties.

2.1.6 Deﬁnition If A and B are two objects of a category C , then the set
of all arrows of C that have source A and target B is denoted HomC (A, B),
or just Hom(A, B) if the category is clear from context. This generalizes the
notation of Deﬁnition 1.2.13.

Thus for each triple A, B, C of objects, composition induces a function

Hom(B, C) × Hom(A, B) −→ Hom(A, C)

A set of the form Hom(A, B) is called a hom set. Other common notations
for Hom(A, B) are C (A, B) and C (AB).

2.1.7 The reference to the set of all arrows from A to B constitutes an
assumption that they do indeed form a set. A category with the property
that Hom(A, B) is a set for all objects A and B is called locally small. All
categories in this book are locally small.

2.1.8 Deﬁnition For any path (f1, f2, . . . , fn) in a category C , deﬁne f1 ◦
f2 ◦ · · · ◦ fn recursively by

f1 ◦ f2 ◦ · · · ◦ fn = (f1 ◦ f2 ◦ · · · ◦ fn−1) ◦ fn, n > 2

18

Categories

2.1.9 Proposition The general associative law. For any path

(f1, f2, . . . , fn)

in a category C and any integer k with 1 < k < n,

(f1 ◦ · · · ◦ fk) ◦ (fk+1 ◦ · · · ◦ fn) = f1 ◦ · · · ◦ fn

In other words, you can unambiguously drop the parentheses.

In this proposition, the notation fk+1 ◦ · · · ◦ fn when k = n − 1 means

simply fn.

This is a standard fact for associative binary operations (see [Jacobson,
1974], Section 1.4) and can be proved in exactly the same way for categories.

2.1.10 Little categories The smallest category has no objects and (of
course) no arrows. The next smallest category has one object and one arrow,
which must be the identity arrow. This category may be denoted 1. Other
categories that will be occasionally referred to are the categories 1 + 1 and
2 illustrated below (the loops are identities). In both cases the choice of the
composites is forced.

(cid:82)

A

(cid:82)

B

1 + 1

(cid:82)

C

(cid:82)
D(cid:45)

2

(2.1)

2.1.11 Categories of sets The category of sets is the category whose
objects are sets and whose arrows are functions (see 1.2.1) with composi-
tion of functions for c and the identity function from S to S for idS. The
statement that this is a category amounts to the statements that composi-
tion of functions is associative and that each identity function idS : S −→ S
satisﬁes f ◦ idS = f and idS ◦ g = g for all f with source S and all g with
target S. The fact that composition of functions is associative follows by
using Deﬁnition 1.2.10 repeatedly:

((h◦g)◦f )(x) = (h◦g)(f (x)) = h(g(f (x))) = h((g◦f )(x)) = (h◦(g◦f ))(x)

The properties of the identity function follow from the deﬁnition of the
identity function (1.2.2).

In this text, the category of sets is denoted Set. There are other categories

whose objects are sets, as follows.

2.1 Basic deﬁnitions

19

2.1.12 Deﬁnition The category of ﬁnite sets, denoted Fin, is the cat-
egory whose objects are ﬁnite sets and whose arrows are all the functions
between ﬁnite sets.

2.1.13 Deﬁnition A partial function from a set S to a set T is a func-
tion with domain S0 and codomain T , where S0 is some subset of S. The
category Pfn of sets and partial functions has all sets as objects and
all partial functions as arrows. If f : S −→ T and g : T −→ V are partial
functions with f deﬁned on S0 ⊆ S and g deﬁned on T0 ⊆ T , the composite
g ◦ f : S −→ V is the partial function from S to V deﬁned on the subset
{x ∈ S0 | f (x) ∈ T0} of S by the requirement (g ◦ f )(x) = g(f (x)).

It is worth checking that composition so deﬁned is associative. Let f : S
−→ T , g : T −→ V and h : V −→ W be partial functions with domains of
deﬁnition S0 ⊆ S, T0 ⊆ T and V0 ⊆ V respectively. We must show

(i) (h ◦ g) ◦ f has the same domain of deﬁnition as h ◦ (g ◦ f ), and
(ii) For x in that common domain of deﬁnition,

((h ◦ g) ◦ f )(x) = (h ◦ (g ◦ f ))(x)

For (i), the domain of deﬁnition of (h ◦ g) ◦ f is the set of x ∈ S such
that f (x) is in the domain of deﬁnition of h ◦ g. The latter is the set of
t ∈ T such that g(t) is in V0. Thus, the domain of deﬁnition of (h ◦ g) ◦ f
is {x ∈ S0 | g(f (x)) ∈ V0}. Since g(f (x)) = (g ◦ f )(x), that is precisely the
domain of deﬁnition of h ◦ (g ◦ f ). As for (ii), the proof is the same as for
ordinary functions (Section 2.1.11).

2.1.14 Deﬁnition Let α be a relation from a set S to a set T and β a
relation from T to U (see 1.1.5). The composite β ◦ α is the relation from
S to U deﬁned as follows: If x ∈ S and z ∈ U , (x, z) ∈ β ◦ α if and only
if there is an element y ∈ T for which (x, y) ∈ α and (y, z) ∈ β. With this
deﬁnition of composition, the category Rel of sets and relations has sets
as objects and relations as arrows. The identity for a set S is the diagonal
relation ∆S = {(x, x) | x ∈ A}.

Other examples of categories whose objects are sets are the category of
sets and injective functions and the category of sets and surjective functions
(Exercises 1 and 2).

Categories also arise in computing science in an intrinsic way. Three ex-
amples of this concern functional programming languages (2.2.1), automata
with typed states (3.2.6) and deductive systems (Section 5.6). In Sections 2.3,
2.4 and 2.5, we discuss some of the ways in which categories arise in mathe-
matics.

20

Categories

2.1.15 Exercises

1. Prove that sets (as objects) and injective functions (as arrows) form a
category with functional composition as the composition operation c.

2. Do the same as Exercise 1 for sets and surjective functions.

3. Show that composition of relations (2.1.14) is associative.

4. Prove the following for any arrow u : A −→ A of a category C . It follows
from these facts that C–3 and C–4 of 2.1.3 characterize the identity arrows
of a category.

a. If g ◦ u = g for every object B of C and arrow g : A −→ B, then u = idA.
b. If u ◦ h = h for every object C of C and arrow h : C −→ A, then

u = idA.

2.2 Functional programming languages

as categories

The intense interest in category theory among researchers in computing sci-
ence in recent years is due in part to the recognition that the constructions
in functional programming languages make a functional programming lan-
guage look very much like a category. The fact that deduction systems are
essentially categories has also been useful in computing science.

In this section we describe the similarities between functional program-
ming languages and categories informally, and discuss some of the technical
issues involved in making them precise. Deduction systems are discussed in
Section 5.6.

2.2.1 Functional programming languages A functional programming
language may be described roughly as one that gives the user some primitive
types and operations and some constructors from which one can produce
more complicated types and operations.

What a pure functional programming language in this sense does not have
is variables or assignment statements. One writes a program by applying
constructors to the types, constants and functions. ‘Running’ a program
consists of applying such an operator to constants of the input type to obtain
a value.

This is what was called ‘function-level programming’ in Backus [1981a]
and [1981b]. (See also [Williams, 1982].) Another widely held point of view
is that functional programming means no assignment statements: variables
may appear but are not assigned to. Most languages called functional pro-
gramming languages (for example Haskell and Miranda) are functional in
this sense.

2.2 Functional programming languages

21

We will discuss Backus-style functional programming languages here.
The lambda calculus, with variables, is discussed in Chapter 6; see par-
ticularly 6.5.3.

2.2.2 The category corresponding to a functional programming
language A functional programming language has:

FPL–1 Primitive data types, given in the language.
FPL–2 Constants of each type.
FPL–3 Operations, which are functions between the types.
FPL–4 Constructors, which can be applied to data types and operations to
produce derived data types and operations of the language.

The language consists of the set of all operations and types derivable
from the primitive data types and primitive operations. The word ‘primitive’
means given in the deﬁnition of the language rather than constructed by
a constructor. Some authors use the word ‘constructor’ for the primitive
operations.

2.2.3 If we make two assumptions about a functional programming lan-
guage and one innocuous change, we can see directly that a functional pro-
gramming language L corresponds in a canonical way to a category C(L).

A–1 We must assume that there is a do-nothing operation idA for each type
A (primitive and constructed). When applied, it does nothing to the
data.

A–2 We add to the language an additional type called 1, which has the
property that from every type A there is a unique operation to 1. We
interpret each constant c of type A as an arrow c : 1 −→ A. This incor-
porates the constants into the set of operations; they no longer appear
as separate data.

A–3 We assume the language has a composition constructor: take an opera-
tion f that takes something of type A as input and produces something
of type B, and another operation g that has input of type B and out-
put of type C; then doing one after the other is a derived operation (or
program) typically denoted f ; g, which has input of type A and output
of type C.

Functional programming languages generally have do-nothing operations
and composition constructors, so A–1 and A–3 ﬁt the concept as it appears in
the literature. The language resulting from the change in A–2 is operationally
equivalent to the original language.

Composition must be associative in the sense that, if either of (f ; g); h or
f ; (g; h) is deﬁned, then so is the other and they are the same operation. We

22

Categories

must also require, for f : A −→ B, that f ; idB and idA; f are deﬁned and are
the same operation as f . That is, we impose the equations f ; idB = f and
idA; f = f on the language. Both these requirements are reasonable in that
in any implementation, the two operations required to be the same would
surely do the same thing.

2.2.4 Under those conditions, a functional programming language L has a
category structure C(L) for which:

FPC–1 The types of L are the objects of C(L).
FPC–2 The operations (primitive and derived) of L are the arrows of C(L).
FPC–3 The source and target of an arrow are the input and output types

of the corresponding operation.

FPC–4 Composition is given by the composition constructor, written in the

reverse order.

FPC–5 The identity arrows are the do-nothing operations.

The reader may wish to compare the discussion in [Pitt, 1986].
Observe that C(L) is a model of the language, not the language itself.
For example, in the category f ; idB = f , but in the language f and f ; idB are
diﬀerent source programs. This is in contrast to the treatment of languages
using context free grammars: a context free grammar generates the actual
language.

2.2.5 Example As a concrete example, we will suppose we have a simple
such language with three data types, NAT (natural numbers), BOOLEAN (true
or false) and CHAR (characters). We give a description of its operations in
categorical style.

(i) NAT should have a constant 0 : 1 −→ NAT and an operation succ : NAT

−→ NAT.

(ii) There should be two constants true, false : 1 −→ BOOLEAN and an op-
eration ¬ subject to the equations ¬ ◦ true = false and ¬ ◦ false =
true.

(iii) CHAR should have one constant c : 1 −→ CHAR for each desired character

c.

(iv) There should be two type conversion operations ord : CHAR −→ NAT
and chr : NAT −→ CHAR. These are subject to the equation chr ◦ ord =
idCHAR. (You can think of chr as operating modulo the number of char-
acters, so that it is deﬁned on all natural numbers.)

An example program is the arrow ‘next’ deﬁned to be the composite
chr ◦ succ ◦ ord : CHAR −→ CHAR. It calculates the next character in order.

2.3 Mathematical structures

23

This arrow ‘next’ is an arrow in the category representing the language, and
so is any other composite of a sequence of operations.

2.2.6 The objects of the category C(L) of this language are the types NAT,
BOOLEAN, CHAR and 1. Observe that typing is a natural part of the syntax in
this approach.

The arrows of C(L) consist of all programs, with two programs being
identiﬁed if they must be the same because of the equations. For example,
the arrow

chr ◦ succ ◦ ord : CHAR −→ CHAR

just mentioned and the arrow

chr ◦ succ ◦ ord ◦ chr ◦ ord : CHAR −→ CHAR

must be the same because of the equation in (iv).

Observe that NAT has constants succ ◦ succ ◦ . . . ◦ succ ◦ 0 where succ
occurs zero or more times. In the exercises, n is the constant deﬁned by
induction by 1 = succ ◦ 0 and n + 1 = succ ◦ n.

Composition in the category is composition of programs. Note that for
composition to be well deﬁned, if two composites of primitive operations are
equal, then their composites with any other program must be equal. For
example, we must have

ord ◦ (chr ◦ succ ◦ ord) = ord ◦ (chr ◦ succ ◦ ord ◦ chr ◦ ord)

as arrows from CHAR to NAT. This is handled systematically in 3.5.8 using
the quotient construction.

This discussion is incomplete, since at this point we have no way to
introduce n-ary operations for n > 1, nor do we have a way of specifying the
ﬂow of control. The ﬁrst will be remedied in Section 5.3.14. Approaches to the
second question are given in Section 5.7.6 and Section 14.2. See also [Wagner,
1986a]. Other aspects of functional programming languages are considered
in 5.3.14 and 5.4.8.

2.2.7 Exercise

1. Describe how to add a predicate ‘nonzero’ to the language of this section.
When applied to a constant of NAT it should give true if and only if the
constant is not zero.

2.3 Mathematical structures as categories

Certain common mathematical structures can be perceived as special types
of categories.

24

Categories

2.3.1 Preordered and ordered sets If S is a set, a subset α ⊆ S × S
is called a binary relation on S. It is often convenient to write xαy as
shorthand for (x, y) ∈ α. We say that α is reﬂexive if xαx for all x ∈ S and
transitive if xαy and yαz implies xαz for all x, y, z ∈ S.

A set S with a reﬂexive, transitive relation α on it is a structure (S, α)
called a preordered set. This structure determines a category C(S, α) de-
ﬁned as follows.

CO–1 The objects of C(S, α) are the elements of S.
CO–2 If x, y ∈ S and xαy, then C(S, α) has exactly one arrow from x to
y, denoted (y, x). (The reader might have expected (x, y) here. This
choice of notation ﬁts better with the right-to-left composition that
we use. Note that the domain of (y, x) is x and the codomain is y.)

CO–3 If x is not related by α to y there is no arrow from x to y.

The identity arrows of C(S, α) are those of the form (x, x); they belong to α
because it is reﬂexive. The transitive property of α is needed to ensure the
existence of the composite described in 2.1.3, so that (z, y) ◦ (y, x) = (z, x).

2.3.2 Example The category C(S, α) for S = {C, D} and

α = {(cid:104)C, C(cid:105), (cid:104)C, D(cid:105), (cid:104)D, D(cid:105)}

is the category 2 exhibited in (2.1), page 18.

2.3.3 Ordered sets A preordered set (S, α) for which α is antisymmetric
(that is xαy and yαx imply x = y) is called an ordered set or poset (for
‘partially ordered set’). Two examples of posets are (R, ≤), the real numbers
with the usual ordering, and for any set S, the poset (P(S), ⊆), the set of
subsets of S with inclusion as ordering.

It is often quite useful and suggestive to think of a category as a general-
ized ordered set, and we will refer to this perception to illuminate construc-
tions we make later.

2.3.4 Semigroups A semigroup is a set S together with an associative
binary operation m : S × S −→ S. The set S is called the underlying set of
the semigroup.

Normally for s and t in S, m(s, t) is written ‘st’ and called ‘multiplica-
tion’, but note that it does not have to satisfy the commutative law; that is,
we may have st (cid:54)= ts. A commutative semigroup is a semigroup whose
multiplication is commutative.

It is standard practice to talk about ‘the semigroup S’, naming the semi-
group by naming its underlying set. This will be done for other mathematical
structures such as posets as well. Mathematicians call this practice ‘abuse

2.3 Mathematical structures

25

of notation’. It is occasionally necessary to be more precise; that happens in
this text in Section 13.1.

2.3.5 Powers We set s1 = s and, for any positive integer k, sk = ssk−1.
Such powers of an element obey the laws sksn = sk+n and (sk)n = skn (for
positive k and n). On the other hand, the law (st)k = sktk requires commu-
tativity.

2.3.6 Empty semigroup We speciﬁcally allow the empty semigroup,
which consists of the empty set and the empty function from the empty set
to itself. (Note that the cartesian product of the empty set with itself is the
empty set.) This is not done in most of the non-category theory literature;
it will become evident later (Section 9.5.2) why we should include the empty
semigroup.

2.3.7 Deﬁnition An identity element e for a semigroup S is an element
of S that satisﬁes the equation se = es = s for all s ∈ S. There can be at
most one identity element in a semigroup (Exercise 3).

2.3.8 Deﬁnition A monoid is a semigroup with an identity element. It
is commutative if its binary operation is commutative.

It follows from the deﬁnition that a monoid is not allowed to be empty:
it must contain an identity element. It also follows that we can extend the
notation in 2.3.5 to 0 by deﬁning x0 to be the identity element of the monoid.
The laws sksn = sk+n and (sk)n = skn then hold for all nonnegative k and
n.

2.3.9 Examples One example of a semigroup is the set of positive inte-
gers with addition as the operation; this is a semigroup but not a monoid.
If you include 0 you get a monoid.

The Kleene closure A∗ of a set A is the set of strings (or lists) of
ﬁnite length of elements of A. We write the lists in parentheses; for example
(a, b, d, a) is an element of {a, b, c, d}∗. Some parts of the computer science
literature call these strings instead of lists and write them this way: ‘abda’.
A∗ includes the empty list () and for each element a ∈ A the list (a) of length
one.

The operation of concatenation makes the Kleene closure a monoid F (A),
called the free monoid determined by A. The empty list is the identity
element. We write concatenation as juxtaposition; thus

(a, b, d, a)(c, a, b) = (a, b, d, a, c, a, b)

26

Categories

Note that the underlying set of the free monoid is A∗, not A. In the
literature, A is usually assumed ﬁnite, but the Kleene closure is deﬁned for
any set A. The elements of A∗ are lists of ﬁnite length in any case. When A
is nonempty, A∗ is an inﬁnite set.

The concept of freeness is a general concept applied to many kinds of

structures. It is treated systematically in Chapter 13.

2.3.10 Deﬁnition A submonoid of a monoid M is a subset S of M with
the properties:

SM–1 The identity element of M is in S.
SM–2 If m, n ∈ S then mn ∈ S. (One says that S is closed under the

operation.)

2.3.11 Examples The natural numbers with addition form a submonoid
of the integers with addition. For another example, consider the integers with
multiplication as the operation, so that 1 is the identity element. Again the
natural numbers form a submonoid, and so does the set of positive natural
numbers, since the product of two positive numbers is another one. Finally,
the singleton set {0} is a subset of the integers that is closed under multi-
plication, and it is a monoid, but it is not a submonoid of the integers on
multiplication because it does not contain the identity element 1.

2.3.12 Monoid as category A monoid M determines a category C(M ).

CM–1 C(M ) has one object, which we will denote ∗; ∗ can be chosen arbi-

trarily. A simple uniform choice is to take ∗ = M .

CM–2 The arrows of C(M ) are the elements of M with ∗ as source and

target.

CM–3 Composition is the binary operation on M .

(This construction is revisited in Section 3.4.)

Thus a category can be regarded as a generalized monoid, or a ‘monoid
with many objects’. This point of view has not been as fruitful in mathe-
matics as the perception of a category as a generalized poset. However, for
computing science, we believe that the monoid metaphor is worth consider-
ing. It is explored in this book primarily in Chapter 12.

2.3.13 Remark Many categorists deﬁne a monoid to be a category with
one object (compare 2.3.12) and a preordered set to be a category in which
every hom set is either empty or a singleton (compare 2.3.1). This can be
justiﬁed by the fact that the category of monoids and the category of one-
object categories are ‘equivalent’ as deﬁned in Section 3.4.

2.4 Categories of sets with structure

27

2.3.14 Exercises

1. For which sets A is F (A) a commutative monoid?

2. Prove that for each object A in a category C , Hom(A, A) is a monoid
with composition of arrows as the operation.

3. Prove that a semigroup has at most one identity element. (Compare Ex-
ercise 4 of Section 2.1.)

2.4 Categories of sets with structure

The typical use of categories has been to consider categories whose objects
are sets with mathematical structure and whose arrows are functions that
preserve that structure. The deﬁnition of category is an abstraction of ba-
sic properties of such systems. Typical examples have included categories
whose objects are spaces of some type and whose arrows are continuous (or
diﬀerentiable) functions between the spaces, and categories whose objects
are algebraic structures of some speciﬁc type and whose arrows are homo-
morphisms between them.

In this section we describe various categories of sets with structure. The

following section considers categories of semigroups and monoids.

Note the contrast with Section 2.3, where we discussed certain mathe-
matical structures as categories. Here, we discuss categories whose objects
are mathematical structures.

2.4.1 Deﬁnition The category of graphs has graphs as objects and
homomorphisms of graphs (see 1.4.1) as arrows. It is denoted GRF. The
category of small graphs (see 1.3.4) and homomorphisms between them is
denoted Grf .

Let us check that the composite of graph homomorphisms is a graph
homomorphism (identities are easy). Suppose φ : G −→ H and ψ : H −→ K
are graph homomorphisms, and suppose that u : m −→ n in G . Then by
deﬁnition φ1(u) : φ0(m) −→ φ0(n) in H , and so by deﬁnition

ψ1(φ1(u)) : ψ0(φ0(m)) −→ ψ0(φ0(n)) in K

Hence ψ ◦ φ is a graph homomorphism.

The identity homomorphism idG is the identity function for both nodes

and arrows.

28

Categories

2.4.2 The category of posets
f : S −→ T is monotone if whenever xαy in S, f (x)βf (y) in T .

If (S, α) and (T, β) are posets, a function

The identity function on a poset is clearly monotone, and the composite
of two monotone functions is easily seen to be monotone, so that posets with
monotone functions form a category. A variation on this is to consider only
strictly monotone functions, which are functions f with the property that
if xαy and x (cid:54)= y then f (x)βf (y) and f (x) (cid:54)= f (y).

In 2.3.1, we saw how a single poset is a category. Now we are considering

the category of posets.

We must give a few words of warning on terminology. The usual word
in mathematical texts for what we have called ‘monotone’ is ‘increasing’ or
‘monotonically increasing’. The word ‘monotone’ is used for a function that
either preserves or reverses the order relation. That is, in mathematical texts
a function f : (X, α) −→ (T, β) is also called monotone if whenever xαy in S,
f (y)βf (x) in T .

2.4.3 ω-complete partial orders We now describe a special type of poset
that has been a candidate for programming language semantics. Actually,
these days more interest has been shown in various special cases of this kind
of poset, but the discussion here shows the approach taken.

Let (S, ≤) be a poset. An ω-chain in S is an inﬁnite sequence s0, s1, s2, . . .
of elements of S for which si ≤ si+1 for all natural numbers i. Note that
repetitions are allowed. In particular, for any two elements s and t, if s ≤ t,
there is a chain s ≤ t ≤ t ≤ t ≤ . . ..

A supremum or least upper bound of a subset T of a poset (S, ≤) is

an element v ∈ S with the following two properties:

SUP–1 For every t ∈ T , t ≤ v.
SUP–2 If w ∈ S has the property that t ≤ w for every t ∈ T , then v ≤ w.

The supremum of a subset T is unique: if v and v(cid:48) are suprema of T ,
then v ≤ v(cid:48) because v(cid:48) satisﬁes SUP–1 and v satisﬁes SUP–2, whereas v(cid:48) ≤ v
because v satisﬁes SUP–1 and v(cid:48) satisﬁes SUP–2. Then v = v(cid:48) by antisym-
metry.

If v satisﬁes SUP–1, it is called an upper bound of T .

2.4.4 Deﬁnition A poset (S, ≤) is an ω-complete partial order, or ω-
CPO, if every chain has a supremum. If the poset also has a minimum
element, it is called a strict ω-CPO. In this context, the minimum element
is usually denoted ⊥ and called ‘bottom’.

Note: This usage of the word ‘complete’ follows the customary usage in
computing science. However, you should be warned that this use of ‘complete’
conﬂicts with standard usage in category theory, where ‘complete’ refers to

2.4 Categories of sets with structure

29

limits, not colimits, so that ω-complete means closed under inﬁmums of all
descending chains. This concept is discussed in Deﬁnitions 9.2.9 and 9.5.2.
For example, every powerset of a set is a strict ω-CPO with respect to

inclusion (Exercise 4).

2.4.5 Example A more interesting example from the point of view of
computing science is the set P of partial functions from some set S to
itself as deﬁned in 2.1.13. A partial function on S can be described as a set
f of ordered pairs of elements of S with the property that if (s, t) ∈ f and
(s, t(cid:48)) ∈ f , then t = t(cid:48). (Compare 1.2.3.)

We give the set P a poset structure by deﬁning f ≤ g to mean f ⊆ g as
a set of ordered pairs. It follows that if f and g are partial functions on S,
then f ≤ g if and only if the domain of f is included in the domain of g and
for every x in the domain of f , f (x) = g(x).

2.4.6 Proposition P is a strict ω-CPO.

Proof. Let T be a chain in P. The supremum t of T is simply the union of
all the sets of ordered pairs in T . This set t is clearly the supremum if indeed
it deﬁnes a partial function. So suppose (x, y) and (x, z) are elements of t.
Then there are partial functions u and v in P with (x, y) ∈ u and (x, z) ∈ v.
Since T is a chain and the ordering of P is inclusion, there is a partial
function w in T containing both (x, y) and (x, z), for example whichever
of u and v is higher in the chain. Since w is a partial function, y = z as
required.

The bottom element of P is the empty function.

2.4.7 Deﬁnition A function f : S −→ T between ω-CPOs is continuous
if whenever s is the supremum of a chain C = (c0, c1, c2, . . .) in S, then f (s)
is the supremum of the image f (C ) = {f (ci) | i ∈ N} in T . A continuous
function between strict ω-CPOs is strict if it preserves the bottom element.

A continuous function is monotone, as can be seen by applying it to a
chain (s, t, t, t, . . .) with s ≤ t. Thus it follows that the image f (C ) of the
chain C in the deﬁnition is itself a chain. See [Barendregt, 1984], pp.10ﬀ, for
a more detailed discussion of continuous functions.

The ω-complete partial orders and the continuous maps between them
form a category. Strict ω-complete partial orders and strict continuous func-
tions also form a category. In fact the latter is a subcategory in the sense to
be deﬁned in 2.6.1.

30

Categories

2.4.8 Functions as ﬁxed points Let f : S −→ S be a set function. An
element x ∈ S is a ﬁxed point of f if f (x) = x. Fixed points of functions
are of interest in computing science because they provide a way of solving
recursion equations. Complete partial orders provide a natural setting for
expressing this idea.

2.4.9 Example Consider the ω-CPO P of partial functions from the set
N of natural numbers to itself. There is a function φ : P −→ P that takes a
partial function h : N −→ N in P to a partial function k deﬁned this way:

(i) k(0) = 1;
(ii) for n > 0, k(n) is deﬁned if and only if h(n − 1) is deﬁned, and k(n) =

nh(n − 1).

For example, if h(n) = n2 for n ∈ N, then

φ(h)(n) =

(cid:189)

1
n(n − 1)2

if n = 0
if n > 0

φ is a continuous function from P to itself. To see this, suppose H =
(h0, h1, . . .) is a chain with supremum h. Then h is the union of all the partial
functions hi as sets of ordered pairs. To show that φ(h) is the supremum of
φ(H ) = (φ(h0), φ(h1), . . .), we must show that for any n, φ(h)(n) is deﬁned
if and only if φ(hi)(n) is deﬁned for some i and then φ(h)(n) = φ(hi)(n).
That says that φ(h) is the union of all the partial functions φ(hi) and so is
the supremum of φ(H ).

Suppose φ(hi)(n) is deﬁned. If n = 0 then φ(hi)(0) = φ(h)(0) = 1 by
deﬁnition of φ. Otherwise, hi(n − 1) is deﬁned and φ(hi)(n) = nhi(n − 1).
Then h(n − 1) = hi(n − 1) since h is the union of the hi, so φ(h)(n) =
nh(n − 1) = nhi(n − 1) = φ(hi)(n).

Suppose φ(h)(n) is deﬁned. Then h(n − 1) is deﬁned and φ(h)(n) =
nh(n − 1). Since h is the union of the hi there must be some i for which
hi(n − 1) is deﬁned and h(n − 1) = hi(n − 1). But then by deﬁnition of φ,
φ(hi)(n) = nhi(n − 1) = nh(n − 1) = φ(h)(n) as required.

The unique ﬁxed point of φ is the factorial function f (n) = n!. In the ﬁrst
place, f (0) = 1 = φ(f )(0). Also, f is a total function and f (n) = nf (n − 1),
so that φ(f ) is deﬁned and by deﬁnition of φ, φ(f )(n) = nf (n − 1) = f (n),
so φ(f ) = f . If also φ(g) = g, then g(0) = 1 and g(n) = φ(g)(n) = ng(n − 1)
so by induction g is the factorial function.

The following proposition, applied to the poset P of partial functions,

warrants the general recursive construction of functions.

2.4 Categories of sets with structure

31

2.4.10 Proposition Let (S, ≤) be a strict ω-CPO and f : S −→ S a con-
tinuous function. Then f has a least ﬁxed point, that is an element p ∈ S
with the property that f (p) = p and for any q ∈ S, if f (q) = q then p ≤ q.

Proof. Form the chain

C = (⊥, f (⊥), f ◦ f (⊥), . . . , f k(⊥), . . .)

Note that indeed f k(⊥) ≤ f k+1(⊥) for k = 0, 1, . . . by induction: ⊥ ≤ f (⊥),
and if f k−1(⊥) ≤ f k(⊥), then f k(⊥) ≤ f k+1(⊥) because f is continuous.

Let p be the supremum of the chain C . Since f is continuous, f (p) is the
supremum of the chain f (C ) = (f (⊥), f 2(⊥), . . .). But p is an upper bound
of f (C ) so f (p) ≤ p. On the other hand, the only element in C not in f (C )
is ⊥, which is less than anything, so f (p) is an upper bound of C . Thus
p ≤ f (p). Hence p = f (p).

If f (q) = q, then ⊥ ≤ q, f (⊥) ≤ f (q) = q, . . ., f n(⊥) ≤ f n(q) = q, and

so on, so that q is an upper bound of C . Hence p ≤ q.

This construction will be made in a wider context in Sections 6.6 and 14.1.

2.4.11 Exercises

1. Let (S, α) and (T, β) be sets with relations on them. A homomorphism
from (S, α) to (T, β) is a function f : S −→ T with the property that if xαy
in S then f (x)βf (y) in T .

a. Show that sets with relations and homomorphisms between them form

a category.

b. Show that if (S, α) and (T, β) are both posets, then f : S −→ T is a

homomorphism of relations if and only if it is a monotone map.

2. Show that (strict) ω-complete partial orders and (strict) continuous func-
tions form a category.
3. Let R+ be the set of nonnegative real numbers. Show that the poset
(R+, ≤) is not an ω-CPO.

4. Show that for every set S, the poset (P(S), ⊆) is a strict ω-CPO.
5.† Give an example of ω-CPOs with a monotone map between them that is
not continuous. (Hint: Adjoin two elements to (Z, ≤) that are greater than
any integer.)
6. Let g : N −→ N be the function such that f (n) = 2n. Exhibit g as the
least ﬁxed point of a continuous function ψ : P −→ P (analogous to the
function φ of Example 2.4.9).

7. The Fibonacci function F is deﬁned by F (0) = 0, F (1) = 1 and F (n) =
F (n − 1) + F (n − 2) for n > 1. Exhibit the Fibonacci function as the least
ﬁxed point of a continuous function from an ω-CPO to itself.

32

Categories

2.5 Categories of algebraic structures

In this section, we discuss the categories whose objects are semigroups or
monoids. These are typical of categories of algebraic structures; we have con-
centrated on semigroups and monoids because transition systems naturally
form monoids. The material in this section will come up primarily in exam-
ples later, and need not be thoroughly understood in order to read the rest
of the book.

2.5.1 Homomorphisms of semigroups and monoids
If S and T are
semigroups, a function h : S −→ T is a homomorphism if for all s, s(cid:48) ∈ S,
h(ss(cid:48)) = h(s)h(s(cid:48)).

A homomorphism of monoids is a semigroup homomorphism between
monoids that preserves the identity elements: if e is the identity element of
the domain, h(e) must be the identity element of the codomain.

2.5.2 Examples The identity function on any monoid is a monoid homo-
morphism. If M is a monoid and S is a submonoid (see 2.3.10), the inclusion
function from S to M is a monoid homomorphism. Another example is the
function that takes an even integer to 0 and an odd integer to 1. This is a
monoid homomorphism from the monoid of integers on multiplication to the
set {0, 1} on multiplication.

Since identity functions are homomorphisms and homomorphisms com-
pose to give homomorphisms (see Exercise 1), we have two categories: Sem
is the category of semigroups and semigroup homomorphisms, and Mon is
the category of monoids and monoid homomorphisms.

2.5.3 Example Let S be a semigroup with element s. Let N+ denote the
semigroup of positive integers with addition as operation. There is a semi-
group homomorphism p : N+ −→ S for which p(k) = sk. That this is a homo-
morphism is just the statement sk+n = sksn (see 2.3.5).

2.5.4 A semigroup homomorphism between monoids need not preserve the
identities. An example of this involves the trivial monoid E with only one
element e (which is perforce the identity element) and the monoid of all
integers with multiplication as the operation, which is a monoid with iden-
tity 1. The function that takes the one element of E to 0 is a semigroup
homomorphism that is not a monoid homomorphism. And, by the way, even
though {0} is a subsemigroup of the integers with multiplication and even
though it is actually a monoid, it is not a submonoid.

2.5 Categories of algebraic structures

33

2.5.5 Inverses of homomorphisms As an example of how to use the
deﬁnition of homomorphism, we show that the inverse of a bijective semi-
group homomorphism is also a semigroup homomorphism. Let f : S −→ T be
a bijective semigroup homomorphism with inverse g. Let t, t(cid:48) ∈ T . We have
to show that g(t)g(t(cid:48)) = g(tt(cid:48)). Since f is injective, it is suﬃcient to show
that

f (g(t)g(t(cid:48))) = f (g(tt(cid:48)))

The right hand side is tt(cid:48) because g is the inverse of f , and the left hand side
is

f (g(t)g(t(cid:48))) = f (g(t))f (g(t(cid:48)))

because f is a homomorphism, but that is also tt(cid:48) since g is the inverse of f .
This sort of theorem is true of other algebraic structures, such as monoids.

It is not true for posets (see 2.7.12 below).

2.5.6 Isomorphisms of semigroups
If a homomorphism of semigroups
has an inverse that is a homomorphism (equivalently, as we just saw, if it
is bijective), we say that the homomorphism is an isomorphism. In this
case, the two semigroups in question have the same abstract structure and
are said to be isomorphic. As we will see later, the property of possessing
an inverse is taken to deﬁne the categorical notion of isomorphism (2.7.4).

It is important to understand that there may in general be many diﬀerent

isomorphisms between isomorphic semigroups (Exercise 4).

We now discuss two important types of examples of monoid homomorph-
isms that will reappear later in the book. The ﬁrst example is a basic property
of free monoids.

2.5.7 Kleene closure induces homomorphisms Let A and B denote
sets, thought of as alphabets. Let f : A −→ B be any set function. We deﬁne
f ∗ : A∗ −→ B∗ by f ∗((a1, a2, . . . , ak)) = (f (a1), f (a2), . . . , f (ak)). In particu-
lar, f ∗() = () and for any a ∈ A, f ∗(a) = f (a).

Then f ∗ is a homomorphism of monoids, a requirement that, in this
case, means it preserves identity elements (by deﬁnition) and concatenation,
which can be seen from the following calculation: Let a = (a1, a2, . . . , am)
and a(cid:48) = (a(cid:48)

n) be lists in A∗. Concatenating them gives the list

2, . . . , a(cid:48)

1, a(cid:48)

aa(cid:48) = (a1, a2, . . . , am, a(cid:48)

1, a(cid:48)

2, . . . , a(cid:48)

n)

Then

f ∗(a)f ∗(a(cid:48)) = f ∗(a1, a2, . . . , am)f ∗(a(cid:48)

1, a(cid:48)

2, . . . , a(cid:48)

= (f (a1), f (a2), . . . , f (am))(f (a(cid:48)

2), . . . , f (a(cid:48)

n))

n)
1), f (a(cid:48)

34

Categories

1), f (a(cid:48)
= (f (a1), f (a2), . . . , f (am), f (a(cid:48)
= f ∗(a1, a2, . . . , am, a(cid:48)
2, . . . , a(cid:48)
n)
= f ∗(aa(cid:48))

1, a(cid:48)

2), . . . , f (a(cid:48)

n))

Thus any set function between sets induces a monoid homomorphism be-
tween the corresponding free monoids.

The function f ∗ is called αf in [Backus, 1981a] and in modern functional

languages is usually called map f or maplist f .

The other important example is a basic construction of number theory.

2.5.8 The remainder function The set Z of all integers forms a mon-
oid with respect to either addition or multiplication. If k is any positive
integer, the set Zk = {0, 1, . . . , k − 1} of remainders of k is also a monoid
with respect to addition or multiplication (mod k). Here are more precise
deﬁnitions.

2.5.9 Deﬁnition Let k be a positive integer and n any integer. Then
n mod k is the unique integer r ∈ Zk for which there is an integer q such
that n = qk + r and 0 ≤ r < k.

It is not diﬃcult to see that there is indeed a unique integer r with these

properties.

Deﬁne an operation ‘+k’ of addition (mod k) by requiring that

r +k s = (r + s) mod k

The operation of addition of the contents of two registers in a microprocessor
may be addition (mod k) for k some power of 2 (often complicated by the
presence of sign bits).

2.5.10 Proposition (Zk, +k) is a monoid with identity 0.

We also have the following.

2.5.11 Proposition The function n (cid:55)→ (n mod k) is a monoid homomorph-
ism from (Z, +) to (Zk, +k).

A similar deﬁnition and proposition can be given for multiplication.

2.6 Constructions on categories

35

2.5.12 Exercises

1. Show that the composite of semigroup (respectively monoid) homomorph-
isms is a semigroup (respectively monoid) homomorphism.

2. Prove Proposition 2.5.10.

3. Prove Proposition 2.5.11.
4.† Exhibit two distinct isomorphisms between the monoid with underly-
ing set {0, 1, 2, 3} and addition (mod 4) as operation and the monoid with
underlying set {1, 2, 3, 4} and multiplication (mod 5) as operation.

5. Using the terminology of 2.5.7, show that if f is an isomorphism then so
is f ∗.

2.6 Constructions on categories

If you are familiar with some branch of abstract algebra (for example the the-
ory of semigroups, groups or rings) then you know that given two structures
of a given type (e.g., two semigroups), you can construct a ‘direct product’
structure, deﬁning the operations coordinatewise. Also, a structure may have
substructures, which are subsets closed under the operations, and quotient
structures, formed from equivalence classes modulo a congruence relation.
Another construction that is possible in many cases is the formation of a
‘free’ structure of the given type for a given set.

All these constructions can be performed for categories. We will outline
the constructions here, except for quotients, which will be described in Sec-
tion 3.5. We will also describe the construction of the slice category, which
does not quite correspond to anything in abstract algebra (although it is
akin to the adjunction of a constant to a logical theory). You do not need
to be familiar with the constructions in other branches of abstract algebra,
since they are all deﬁned from scratch here.

2.6.1 Deﬁnition A subcategory D of a category C is a category for
which:

S–1 All the objects of D are objects of C and all the arrows of D are arrows

of C (in other words, D0 ⊆ C0 and D1 ⊆ C1).

S–2 The source and target of an arrow of D are the same as its source and
target in C (in other words, the source and target maps for D are the
restrictions of those for C ). It follows that for any objects A and B of
D, HomD (A, B) ⊆ HomC (A, B).

S–3 If A is an object of D then its identity arrow idA in C is in D.

36

Categories

S–4 If f : A −→ B and g : B −→ C in D, then the composite (in C ) g ◦ f is

in D and is the composite in D.

2.6.2 Examples As an example, the category Fin of ﬁnite sets and all
functions between them is a subcategory of Set, and in turn Set is a sub-
category of the category of sets and partial functions between sets (see 2.1.12
and 2.1.13). These examples illustrate two phenomena:

(i) If A and B are ﬁnite sets, then HomFin(A, B) = HomSet(A, B). In
other words, every arrow of Set between objects of Fin is an arrow of
Fin.

(ii) The category of sets and the category of sets and partial functions, on
the other hand, have exactly the same objects. The phenomenon of (i)
does not occur here: there are generally many more partial functions
between two sets than there are full functions.

Example (i) motivates the following deﬁnition.

2.6.3 Deﬁnition If D is a subcategory of C and for every pair of objects
A, B of D, HomD (A, B) = HomC (A, B), then D is a full subcategory of
C .

Thus Fin is a full subcategory of Set but Set is not a full subcategory

of the category of sets and partial functions.

Example 2.6.2(ii) also motivates a (less useful) deﬁnition, as follows.

2.6.4 Deﬁnition If D is a subcategory of C with the same objects, then
D is a wide subcategory of C .

Thus in the case of a wide subcategory, only the arrows are diﬀerent from
those of the larger category. In 2.7.13 we provide an improvement on this
concept.

As an example, Set is a wide subcategory of the category Pfn of sets

and partial functions.

2.6.5 Example Among all the objects of the category of semigroups are
the monoids, and among all the semigroup homomorphisms between two
monoids are those that preserve the identity. Thus the category of monoids
is a subcategory of the category of semigroups that is neither wide nor full
(for the latter, see 2.5.4).

As it stands, being a subcategory requires the objects and arrows of
the subcategory to be identical with some of the objects and arrows of the
category containing it. This requires an uncategorical emphasis on what
something is instead of on the speciﬁcation it satisﬁes. We will return to
this example in 2.8.13 and again in 3.1.7.

2.6 Constructions on categories

37

2.6.6 The product of categories
If C and D are categories, the prod-
uct C × D is the category whose objects are all ordered pairs (C, D) with C
an object of C and D an object of D, and in which an arrow (f, g) : (C, D)
−→ (C(cid:48), D(cid:48)) is a pair of arrows f : C −→ C(cid:48) in C and g : D −→ D(cid:48) in D. The
identity of (C, D) is (idC, idD). If (f (cid:48), g(cid:48)) : (C(cid:48), D(cid:48)) −→ (C(cid:48)(cid:48), D(cid:48)(cid:48)) is another
arrow, then the composite is deﬁned by

(f (cid:48), g(cid:48)) ◦ (f, g) = (f (cid:48) ◦ f, g(cid:48) ◦ g) : (C, D) −→ (C(cid:48)(cid:48), D(cid:48)(cid:48))

2.6.7 The dual of a category Given any category C , you can construct
another category denoted C op by reversing all the arrows. The dual or
opposite C op of a category C is deﬁned by:
D–1 The objects and arrows of C op are the objects and arrows of C .
D–2 If f : A −→ B in C , then f : B −→ A in C op.
D–3 If h = g ◦ f in C , then h = f ◦ g in C op.

The meaning of D–2 is that source and target have been reversed. It is
easy to see that the identity arrows have to be the same in the two categories
C and C op and that C–1 through C–4 of Section 2.1 hold, so that C op is a
category.

2.6.8 Example
If M is a monoid, then the opposite of the category C(M )
is the category determined by a monoid M op; if xy = z in M , then yx = z
in M op. (Hence if M is commutative then C(M ) is its own dual. Compare
Exercise 6 of 3.3.) Similar remarks may be made about the opposite of the
category C(P ) determined by a poset P . The opposite of the poset (Z, ≤),
for example, is (Z, ≥).

2.6.9 Both the construction of the product of two categories and the con-
struction of the dual of a category are purely formal constructions. Even
though the original categories may have, for example, structure-preserving
functions of some kind as arrows, the arrows in the product category are
simply pairs of arrows of the original categories.

Consider Set, for example. Let A be the set of letters of the English
alphabet. The function v : A −→ {0, 1} that takes consonants to 0 and vowels
to 1 is an arrow of Set. Then the arrow (idA, v) : (A, A) −→ (A, {0, 1}) of
Set × Set is not a function, not even a function of two variables; it is merely
the arrow of a product category and as such is an ordered pair of functions.
A similar remark applies to duals. In Setop, v is an arrow from {0, 1} to

A. And that is all it is. It is in particular not a function from {0, 1} to A.

Nevertheless, it is possible in some cases to prove that the dual of a
familiar category is essentially the same as some other familiar category.
One such category is Fin, see 3.4.6.

38

Categories

The product of categories is a formal way to make constructions depen-
dent on more than one variable. The major use we make of the concept of
dual is that many of the deﬁnitions we make have another meaning when
applied to the dual of a category that is often of independent interest. The
phrase dual concept or dual notion is often used to refer to a concept or
notion applied in the dual category.

2.6.10 Slice categories If C is a category and A any object of C , the
slice category C /A is described this way:

SC–1 An object of C /A is an arrow f : C −→ A of C for some object C.
SC–2 An arrow of C /A from f : C −→ A to f (cid:48) : C(cid:48) −→ A is an arrow h : C

−→ C(cid:48) with the property that f = f (cid:48) ◦ h.

SC–3 The composite of h : f −→ f (cid:48) and h(cid:48) : f (cid:48) −→ f (cid:48)(cid:48) is h(cid:48) ◦ h.

It is necessary to show that h(cid:48) ◦ h, as deﬁned in SC–2, satisﬁes the re-
quirements of being an arrow from f to f (cid:48)(cid:48). Let h : f −→ f (cid:48) and h(cid:48) : f (cid:48) −→ f (cid:48)(cid:48).
This means f (cid:48) ◦ h = f and f (cid:48)(cid:48) ◦ h(cid:48) = f (cid:48). To show that h(cid:48) ◦ h : f −→ f (cid:48)(cid:48) is an
arrow of C /A, we must show that f (cid:48)(cid:48) ◦ (h(cid:48) ◦ h) = f . That follows from this
calculation:

f (cid:48)(cid:48) ◦ (h(cid:48) ◦ h) = (f (cid:48)(cid:48) ◦ h(cid:48)) ◦ h = f (cid:48) ◦ h = f

The usual notation for arrows in C /A is deﬁcient: the same arrow h can
satisfy f = f (cid:48) ◦ h and g = g(cid:48) ◦ h with f (cid:54)= g or f (cid:48) (cid:54)= g(cid:48) (or both). Then h : f
−→ f (cid:48) and h : g −→ g(cid:48) are diﬀerent arrows of C /A.

2.6.11 The importance of slice categories comes in part with their connec-
tion with indexing. An S-indexed set is a set X together with a function
τ : X −→ S. If x ∈ X and τ (x) = s then we say x is of type s, and we also
refer to X as a typed set.

The terminology ‘S-indexed set’ is that used by category theorists. Many
mathematicians would cast the discussion in terms of the collection {τ −1(s) |
s ∈ S} of subsets of X, which would be called a family of sets indexed
by S.

2.6.12 Example The set G = G0 ∪ G1 of objects and arrows of a graph
G is an example of a typed set, typed by the function τ : G −→ {0, 1} that
takes a node to 0 and an arrow to 1. Note that this depends on the fact that
a node is not an arrow: G0 and G1 are disjoint.

2.6.13 Indexed functions A function from a set X typed by S to a set
X (cid:48) typed by the same set S that preserves the typing (takes an element of
type s to an element of type s) is exactly an arrow of the slice category
Set/S. Such a function is called an indexed function or typed function.

2.6 Constructions on categories

39

It has been fruitful for category theorists to pursue this analogy by thinking
of objects of any slice category C /A as objects of C indexed by A.

2.6.14 Example A graph homomorphism f : G −→ H corresponds to
a typed function according to the construction in Example 2.6.12. How-
ever, there are typed functions between graphs that are not graph homo-
morphisms, for example the function from the graph (1.1), page 9, to the
graph (1.3), page 10, deﬁned by

1 (cid:55)→ 1, 2 (cid:55)→ n, a (cid:55)→ 0, b (cid:55)→ 0, c (cid:55)→ succ

This is not a graph homomorphism because it does not preserve source and
target.

2.6.15 Example Let (P, α) be a poset and let C(P ) be the corresponding
category as in 2.3.1. For an element x ∈ P , the slice category C(P )/x is the
category corresponding to the set of elements greater than or equal to x.
The dual notion of coslice gives the set of elements less than or equal to a
given element.

2.6.16 The free category generated by a graph For any given graph
G there is a category F (G ) whose objects are the nodes of G and whose
arrows are the paths in G . Composition is deﬁned by the formula

(f1, f2, . . . , fk) ◦ (fk+1, . . . , fn) = (f1, f2, . . . , fn)

This composition is associative, and for each object A, idA is the empty path
from A to A. The category F (G ) is called the free category generated
by the graph G . It is also called the path category of G .

2.6.17 Examples The free category generated by the graph with one node
and no arrows is the category with one object and only the identity arrow,
which is the empty path. The free category generated by the graph with one
node and one loop on the node is the free monoid with one generator (Kleene
closure of a one-letter alphabet); this is isomorphic with the nonnegative in-
tegers with + as operation.

The free category generated by the graph in Example 1.3.8 has the fol-

lowing arrows

(a) An arrow id1 : 1 −→ 1.
(b) For each nonnegative integer k, the arrow succk : n −→ n. This is the
path (succ, succ, . . . , succ) (k occurrences of succ). This includes k = 0
which gives idn.

40

Categories

(c) For each nonnegative integer k, the arrow succk ◦ 0 : 1 −→ n. Here k = 0

gives 0 : 1 −→ n.

Composition obeys the rule succk ◦ succm = succk+m.

2.6.18 It is useful to regard the free category generated by any graph as
analogous to Kleene closure (free monoid) generated by a set (as in 2.3.9).
The paths in the free category correspond to the strings in the Kleene closure.
The diﬀerence is that you can concatenate any symbols together to get a
string, but arrows can be strung together only head to tail, thus taking into
account the typing.

In 13.2.3 we give a precise technical meaning to the word ‘free’.

2.6.19 Exercises

1. Let M be a monoid. Show that the opposite of the category C(M ) deter-
mined by M is also the category determined by a monoid, called M op.

2. Do the same as the preceding exercise for posets.

3. Give examples of posets P , Q and R for which C(P ) (the category deter-
mined by the poset) is a wide but not full subcategory of C(Q) and C(P ) is
a full but not wide subcategory of C(R).
4.† Show by example that the requirement S–3 in 2.6.1 does not follow from
the other requirements.

2.7 Properties of objects and
arrows in a category

The data in the deﬁnition of category can be used to deﬁne properties that
the objects and arrows of the category may have. A property that is deﬁned
strictly in terms of the role the object or arrow has in the category, rather
than in terms of what it really is in any sense, is called a categorical deﬁ-
nition. Such deﬁnitions are abstract in the sense that a property a thing can
have is deﬁned entirely in terms of the external interactions of that thing
with other entities.

The examples of categorical deﬁnitions in this section and the next are of
several simple concepts that can be expressed directly in terms of the data
used in the deﬁnition of category. Other concepts, such as limit, naturality
and adjunction, require deeper ideas that will be the subject of succeeding
chapters.

2.7 Properties of objects and arrows

41

2.7.1 Isomorphisms
In general, the word ‘isomorphic’ is used in a math-
ematical context to mean indistinguishable in form. We have already used
it in this way in 2.5.6. It turns out that it is possible to translate this into
categorical language in a completely satisfactory way. To do this, we ﬁrst
need the concept of inverse.

2.7.2 Deﬁnition Suppose f : A −→ B and g : B −→ A are arrows in a
category for which f ◦ g is the identity arrow of B and g ◦ f is the identity
arrow of A. Then g is an inverse to f , and, of course, f is an inverse to g.

2.7.3 As an example of how to use the deﬁnition of inverse, we show that
if f : A −→ B has an inverse, it has only one. Suppose g : B −→ A and h : B
−→ A have the properties that g ◦ f = h ◦ f = idA and f ◦ g = f ◦ h = idB.
Then

g = g ◦ idB = g ◦ (f ◦ h) = (g ◦ f ) ◦ h = idA ◦ h = h

Note that this does not use the full power of the hypothesis.

From this uniqueness, we can conclude that if f : A −→ A has an inverse,
then (f −1)−1 = f . Proof: All four of the following equations are true by
deﬁnition of inverse:
(i) f −1 ◦ f = idA.
(ii) f ◦ f −1 = idA.
(iii) f −1 ◦ (f −1)−1 = idA.
(iv) (f −1)−1 ◦ f −1 = idA.
It follows that both f and (f −1)−1 are arrows g such that f −1 ◦ g = idA and
g ◦ f −1 = idA. Thus f = (f −1)−1 by uniqueness of the inverse of f −1.

2.7.4 Deﬁnition Suppose that C is a category and that A and B are two
objects of C . An arrow f : A −→ B is said to be an isomorphism if it has
an inverse. In that case, we say that A is isomorphic to B, written A ∼= B.
In a monoid, an element which is an isomorphism in the corresponding

category is usually called invertible.

2.7.5 Deﬁnition An arrow f : A −→ A in a category (with the source and
target the same) is called an endomorphism. If it is invertible, it is called
an automorphism.

2.7.6 Examples Any identity arrow in any category is an isomorphism
(hence an automorphism). In the category determined by a partially or-
dered set, the only isomorphisms are the identity arrows. If, in the category
determined by a monoid, every arrow is an isomorphism the monoid is called

42

Categories

a group. Because of this, a category in which every arrow is an isomorphism
is called a groupoid.

2.7.7 Deﬁnition A property that objects of a category may have is pre-
served by isomorphisms if for any object A with the property, any object
isomorphic to A must also have the property.

2.7.8 To show that two objects are isomorphic, it is suﬃcient to exhibit an
isomorphism between them. To show they are not isomorphic is often more
diﬃcult, since the deﬁnition requires checking every arrow between the two
objects. In practice it is almost always done by ﬁnding some property that
is preserved by isomorphisms and is possessed by one of the objects and not
possessed by the other. See 2.7.11.

2.7.9 Proposition A function in Set is an isomorphism if and only if it
is a bijection.

Proof. Suppose ﬁrst that f : S −→ T is an isomorphism; it therefore has
an inverse g : T −→ S. Then (i) f is injective, for if f (x) = f (y), then x =
g(f (x)) = g(f (y)) = y. Also (ii) f is surjective, for if t ∈ T , then f (g(t)) = t.
Conversely, suppose that f : S −→ T is bijective. Deﬁne g : T −→ S by
saying that g(t) is the unique element x ∈ S for which f (x) = t. There
is such an element x because f is surjective, and x is unique because f
is injective. The deﬁnition itself says that f (g(t)) = t for any t ∈ T , so in
particular f (g(f (x))) = f (x); since f is known to be injective, it follows that
g(f (x)) = x, as required.

It follows that two ﬁnite sets are isomorphic (in the category of sets) if

and only if they have the same number of elements.

2.7.10 Example A graph homomorphism φ : G −→ H is an isomorphism
if and only if both φ0 and φ1 are bijections. This follows immediately from
Exercise 3 of Section 1.4.

2.7.11 Example For ordered sets, the situation is diﬀerent. For example,
the following partially ordered sets A and B containing three elements each
are not isomorphic in the category of partially ordered sets and monotone
functions: A consists of three elements a < b < c and B consists of three
elements x < y, x < z, but no relation holds between y and z.

It seems clear that A and B are not isomorphic, but it might seem hard
to say why. One way is simply to observe that A is totally ordered (for any
two elements u and v, either u < v or v < u) and B is not totally ordered.

2.7 Properties of objects and arrows

43

Since being totally ordered is preserved by isomorphisms, the two posets
cannot be isomorphic.

An alternative proof is possible in the case of the preceding example: exhaus-
tively consider all 6 bijections between the two posets and show that none
of those that are monotone have inverses that are monotone. This approach
clearly is unacceptably time-consuming for any interesting problem.

It is often quite hard to show that two structures are not isomorphic. One often
approaches this problem by trying to ﬁnd numerical invariants. In the case at
hand, a simple invariant is the depth, that is the length of the longest totally
ordered subset: the depth of A is 3 and the depth of B is 2. A set of invariants
is called complete if it is suﬃcient to decide the isomorphism class. Complete
sets of invariants rarely exist. Depth is suﬃcient in the case of 2.7.11 but is
certainly not in general.

2.7.12 It is often the case that in a category of sets with structure and
structure-preserving functions, a structure-preserving function that is a bi-
jection is automatically an isomorphism. This is not always the case, as is
illustrated by the poset example in 2.7.11. In fact, the bijection from A to B
that takes x to a, y to b and z to c preserves the order relation. Of course,
it also takes a pair of incomparable elements to comparable ones, but the
point is it preserves the order, insofar as it exists.

2.7.13 From the categorist’s point of view there is no reason to distinguish
between two isomorphic objects in a category, since the interesting fact about
a mathematical object is the way it relates to other mathematical objects
and two isomorphic objects relate to other objects in the same way. For this
reason, the concept of wide category (Deﬁnition 2.6.4) is not in the spirit of
category theory. What really should matter is whether the subcategory con-
tains an isomorphic copy of every object in the big category. This motivates
the following deﬁnition.

2.7.14 Deﬁnition A subcategory D of a category C is said to be a rep-
resentative subcategory if every object of C is isomorphic to some object
of D.

2.7.15 Example Let D be the category whose objects are the empty set
and all sets of the form {1, 2, . . . , n} for some positive integer n and whose
arrows are all the functions between them. Then D is a representative subcat-
egory of Fin (Deﬁnition 2.1.12), since there is a bijection from any nonempty
ﬁnite set to some set of the form {1, 2, . . . , n}. Note that D is also full in
Fin.

44

Categories

2.7.16 Terminal and initial objects An object T of a category C is
called terminal if there is exactly one arrow A −→ T for each object A of
C . We usually denote the terminal object by 1 and the unique arrow A −→ 1
by (cid:104)(cid:105).

The dual notion (see 2.6.7), an object of a category that has a unique
arrow to each object (including itself), is called an initial object and is
often denoted 0.

2.7.17 Examples
In the category of sets, the empty set is initial and any
one-element set is terminal. Thus the category of sets has a unique initial
object but many terminal objects. The one-element monoid is both initial
and terminal in the category of monoids. In the category determined by a
poset, an object is initial if and only if it is an absolute minimum for the
poset, and it is terminal if and only if it is an absolute maximum. Since there
is no largest or smallest whole number, the category determined by the set
of integers with its natural order (there is an arrow from m to n if and only
if m ≤ n) gives an example of a category without initial or terminal object.
In the category of semigroups, the empty semigroup (see 2.3.6) is the
initial object and any one-element semigroup is a terminal object. On the
other hand, the category of nonempty semigroups does not have an initial
object. Warning: To prove this, it is not enough to say that the initial object
in the category of semigroups is the empty semigroup and that semigroup is
missing here! You have to show that no other object can be the initial object
in the smaller category. One way to do this is to let U be the semigroup with
two elements 1 and e with 1 · e = e · 1 = e, 1 · 1 = 1 and e · e = e. Then any
nonempty semigroup S has two homomorphisms to U : the constant function
taking everything to 1 and the one taking everything to e. Thus no nonempty
semigroup S can be the initial object.

2.7.18 Proposition Any two terminal (respectively initial) objects in a
category are isomorphic.

Proof. Suppose T and T (cid:48) are terminal objects. Since T is terminal, there is
an arrow f : T (cid:48) −→ T . Similarly, there is an arrow g : T −→ T (cid:48). The arrow
f ◦ g : T −→ T is an arrow with target T . Since T is a terminal object of the
category, there can be only one arrow from T to T . Thus it must be that
f ◦ g is the identity of T . An analogous proof shows that g ◦ f is the identity
of T (cid:48).

2.7.19 Constants
In Set, an element x of a set A is the image of a func-
tion from a singleton set to A that takes the unique element of the singleton
to x. Thus if we pick a speciﬁc singleton {∗} and call it 1, the elements of
the set A are in one to one correspondence with Hom(1, A), which is the set

2.7 Properties of objects and arrows

45

of functions from the terminal object to A. Moreover, if f : A −→ B is a set
function and x is an element of A determining the function x : 1 −→ A, then
the element f (x) of B is essentially the same thing as the composite f ◦ x : 1
−→ B. Because of this, the categorist typically thinks of an element x ∈ A
as being the constant x : 1 −→ A.

An arrow 1 −→ A in a category, where 1 is the terminal object, is called a
constant of type A. Thus each element of a set is a constant in Set. On the
other hand, each monoid M has just one constant 1 −→ M in the category
of monoids, since monoid homomorphisms must preserve the identity. The
name ‘constant’ is explained by Exercise 7.

The more common name in the categorical literature for a constant
is global element of A, a name that comes from sheaf theory (see Sec-
tion 15.5).

A terminal object is an object with exactly one arrow (cid:104)(cid:105) : A −→ 1 to it from each
object A. So the arrows to 1 are not interesting. Global elements are arrows
from the terminal object. There may be none or many, so they are interesting.

2.7.20 If 1 and 1(cid:48) are two terminal objects in a category and x : 1 −→ A
and x(cid:48) : 1(cid:48) −→ A are two constants with the property that x(cid:48) ◦ (cid:104)(cid:105) = x (where
(cid:104)(cid:105) is the unique isomorphism from 1 to 1(cid:48)), then we regard x and x(cid:48) as the
same constant. Think about this comment as it applies to elements in the
category of sets, with two diﬀerent choices of terminal object, and you will
see why.

2.7.21 Exercises

1. Show that if f : A −→ B and g : B −→ C are isomorphisms in a category
with inverses f −1 : B −→ A and g−1 : C −→ B, then g ◦ f is an isomorphism
with inverse f −1 ◦ g−1. (This is sometimes called the ‘Shoe–Sock Theorem’:
to undo the act of putting on your socks, then your shoes, you have to take
oﬀ your shoes, then your socks.)

2. Give examples of posets P1, P2 and P3 with the following properties:

(a) P1 = P1
(b) P2 (cid:54)= P2
(c) P3 is not isomorphic to P3

op.
op but P2 is isomorphic to P2

op.

op.

(See Exercise 2 of Section 2.6.)
3.† Give examples of a monoid M for which M (cid:54)= M op (meaning the binary
operations are diﬀerent) but M and M op are isomorphic (compare 2.6.8) and
one for which M and M op are not isomorphic. (See Exercise 1 of Section 2.6.)

46

Categories

4. Show that a poset isomorphic to a totally ordered set must be totally
ordered.

5. Let (P, ≤) be a poset. Show that in the corresponding category C(P, ≤)
(see 2.3.1), no two distinct objects are isomorphic.

6. Show that in the category of semigroups (respectively monoids), the iso-
morphisms are exactly the bijective homomorphisms. (This is not true for
ordered sets, as we saw in 2.7.12. It is true in any variety of universal alge-
bras, and it is not true in most interesting categories of topological spaces.)

7. Show that the following two statements about a set function f : A −→ B
are equivalent.

(a) f = k ◦ (cid:104)(cid:105), where k : 1 −→ B (hence is a constant in the sense of 2.7.19)
and (cid:104)(cid:105) : A −→ 1 is the unique function given by deﬁnition of terminal
object.

(b) For all x and y in A, f (x) = f (y).

8. Show that in the category of graphs and graph homomorphisms, the graph
with one node and one arrow is the terminal object.

9. An arrow f : A −→ A in a category is idempotent if f ◦ f = f . Show
that in Set a function is idempotent if and only if its image is the same as
its set of ﬁxed points. (For example, applying a speciﬁc sorting method to a
set of ﬁles is idempotent, since if you sort an already sorted ﬁle you leave it
the same.)

10. An idempotent (see the preceding problem) f : A −→ A in a category is
split if there is an object B and functions g : A −→ B and h : B −→ A for
which h ◦ g = f and g ◦ h = idB.

a. Show that every idempotent in Set is split.
b.† Give an example of a category with a non-split idempotent.

11. A category in which every arrow is an isomorphism is a groupoid. A
category in which every arrow is an identity arrow is called discrete. Prove
or disprove:

(i) Any two objects in a groupoid are isomorphic.
(ii) A groupoid in which no two distinct objects are isomorphic is discrete.
(iii) A poset P for which C(P ) is a groupoid is discrete.

2.8 Monomorphisms and subobjects

2.8 Monomorphisms and subobjects

47

2.8.1 Monomorphisms A function f : A −→ B in Set is injective if for
any x, y ∈ A, if x (cid:54)= y, then f (x) (cid:54)= f (y). A monomorphism is a particular
type of arrow in a category which generalizes the concept of injective func-
tion; in particular, a monomorphism in the category of sets is exactly an
injective function. If f is an arrow in an arbitrary category, we use the same
deﬁnition, except for one change required because the concept of ‘element’
no longer makes sense.

2.8.2 Deﬁnition f : A −→ B is a monomorphism if for any object T of
the category and any arrows x, y : T −→ A, if x (cid:54)= y, then f ◦ x (cid:54)= f ◦ y.

We often write f : A (cid:41)−→ B to indicate that f is a monomorphism and

say that f is monic or that f is mono.

In Deﬁnition 2.8.2 and many like it, what replaces the concept of element
of A is an arbitrary arrow into A. In this context, an arbitrary arrow a : T
−→ A is called a variable element of A, parametrized by T . When a is
treated as a variable element and f has source A, one may write f (a) for
f ◦ a. Using this notation, f is a monomorphism if for any variable elements
x, y : T −→ A, if x (cid:54)= y, then f (x) (cid:54)= f (y).

The following theorem validates the claim that ‘monomorphism’ is the

categorical version of ‘injective’.

2.8.3 Theorem In the category of sets, a function is injective if and only
if it is a monomorphism.

Proof. Suppose f : A −→ B is injective, and let a, a(cid:48) : T −→ A be variable
elements of A. If a (cid:54)= a(cid:48) then there is an (ordinary) element t ∈ T for which
a(t) (cid:54)= a(cid:48)(t). Then f (a(t)) (cid:54)= f (a(cid:48)(t)), so f ◦ a (cid:54)= f ◦ a(cid:48). Hence f is monic.

Conversely, suppose f is monic. Since global elements (see 2.7.19) are
elements, this says that for any global elements x, y : 1 −→ A with x (cid:54)= y,
f ◦ x (cid:54)= f ◦ y, i.e., f (x) (cid:54)= f (y), which means that f is injective.

2.8.4 Examples In most familiar categories of sets with structure and
functions that preserve structure, the monomorphisms are exactly the injec-
tive functions. In particular, the monomorphisms in Mon are the injective
homomorphisms (proved in 2.8.5 below). Some other examples are in the
exercises. This is evidence that Deﬁnition 2.8.2 is the correct categorical
deﬁnition generalizing the set-theoretic concept of injectivity.

In the category determined by a poset, every arrow is monic. A monic
element of the category determined by a monoid is generally called left
cancellable.

48

Categories

An isomorphism in any category is a monomorphism. For suppose f is

an isomorphism and f ◦ x = f ◦ y. This calculation shows that x = y:

x = f −1 ◦ f ◦ x = f −1 ◦ f ◦ y = y

2.8.5 We now show that a monomorphism in the category of monoids is
an injective homomorphism, and conversely.

Let f : M −→ M (cid:48) be a monoid homomorphism. Suppose it is injective.
Let g, h : V −→ M be homomorphisms for which f ◦ g = f ◦ h. For any
v ∈ V , f (g(v)) = f (h(v)), so g(v) = h(v) since f is injective. Hence g = h.
It follows that f is a monomorphism. Essentially the same proof works in
other categories of structures and structure-preserving maps – if the map is
injective it is a monomorphism for the same reason as in Set.

However, the converse deﬁnitely does not work that way. The proof for
Set in Theorem 2.8.3 above uses distinct global elements x and y, but a
monoid need not have distinct global elements. For example, let N denote
the monoid of nonnegative integers with addition as operation. Then the
only global element of N on addition is 0. So we have to work harder to get
a proof.

Suppose f is a monomorphism. Let x, y ∈ M be distinct elements. Let
px : N −→ M take k to xk and similarly deﬁne py; px and py are homo-
morphisms since for all x, xk+n = xkxn (see 2.3.5 and the discussion after
Deﬁnition 2.8.2). Since x (cid:54)= y, px and py are distinct homomorphisms. If
f (x) = f (y) then for all positive integers k,

f (px(k)) = f (xk) = f (x)k = f (y)k = f (yk) = f (py(k))

so that f ◦ px = f ◦ py which would mean that f is not a monomorphism.
Thus we must have f (x) (cid:54)= f (y) so that f is injective.

The trick in the preceding paragraph was to ﬁnd an object (N here) that
allows one to distinguish elements of the arbitrary monoid M . In Set, the
corresponding object was the terminal object, but that does not work for
Mon: each monoid has exactly one global element because a map from the
one-element monoid must have the identity element as value. An object that
allows one to (uniquely) distinguish elements in a category of sets with struc-
ture is said to ‘represent the underlying functor’. This concept is presented
in 4.3.10 and 4.5.1.

We now state two propositions that give some elementary properties of

monomorphisms.

2.8.6 Proposition Suppose f : A −→ B and g : B −→ C in a category C .
Then

(a) If f and g are monomorphisms, so is g ◦ f .

2.8 Monomorphisms and subobjects

49

(b) If g ◦ f is a monomorphism, so is f .

Proof. We prove the second statement and leave the ﬁrst to you (Exercise 2).
Suppose g ◦ f is a monomorphism. To show that f is a monomorphism,
assume f ◦ x = f ◦ y for some arrows x, y : C −→ A. Then

(g ◦ f ) ◦ x = g ◦ (f ◦ x) = g ◦ (f ◦ y) = (g ◦ f ) ◦ y

so, since g ◦ f is a monomorphism, x = y.

2.8.7 Proposition Let m : C −→ 0 be a monomorphism into an initial
object. Then m is an isomorphism.

Proof. Let i : 0 −→ C be the unique arrow given by deﬁnition of initial object.
Then m ◦ i and id0 are both arrows from 0 to 0 and so must be the same.
It remains to show that i ◦ m = idC. This follows from the fact that m ◦ i ◦
m = m ◦ idC and that m is a monomorphism.

2.8.8 Subobjects The concept of subobject is intended to generalize the
concept of subset of a set, submonoid of a monoid, subcategory of a category,
and so on. This idea cannot be translated exactly into categorical terms, since
the usual concept of subset violates the strict typing rules of category theory:
to go from a subset to a set requires a change of type, so there is no feasible
way to say that the same element x is in both a set and a subset of the set.
Because of this, any categorical deﬁnition of subobject will not give ex-
actly the concept of subset when applied to the category of sets. However,
the usual deﬁnition of subobject (which we give here in Deﬁnition 2.8.11)
produces, in Set, a concept that is naturally equivalent to the concept of
subset in a strong sense that we will describe in 2.8.12. The deﬁnition, when
applied to sets, deﬁnes subset in terms of the inclusion function.

2.8.9 We need a preliminary idea. If f : A −→ B is an arrow in a category,
and for some arrow g : C −→ B there is an arrow h : A −→ C for which f =
g ◦ h, we say f factors through g. This is because the equation g ◦ h = f
can be solved for h.

The use of the word ‘factor’ shows the explicit intention of categorists to work
with functions in an algebraic manner: a category is an algebra of functions.

Suppose f0 : C0 −→ C and f1 : C1 −→ C are monomorphisms in a cate-

gory. Let us say that f0 ∼ f1 if each factors through the other.

50

Categories

2.8.10 Proposition Let f0 ∼ f1. Then the factors implied by the deﬁni-
tion of ∼ are unique and are inverse isomorphisms. Moreover, the relation
∼ is an equivalence relation on the collection of arrows with target C.

Proof. The deﬁnition implies the existence of arrows g : C0 −→ C1 and h : C1
−→ C0 such that f1 ◦ g = f0 and f0 ◦ h = f1. The arrows g and h are unique
because f0 and f1 are monomorphisms. Moreover, f1 ◦ g ◦ h = f0 ◦ h = f1 =
f1 ◦ id; since f1 is a monomorphism, we conclude that g ◦ h = id. Similarly,
h ◦ g = id.

That ∼ is reﬂexive follows by taking the factor to be the identity arrow,
and it is symmetric by deﬁnition. For transitivity, you get the required factor
by composing the given factors; we leave the details to you.

2.8.11 Deﬁnition In a category C , a subobject of an object C is an
equivalence class of monomorphisms under ∼. The subobject is a proper
subobject if it does not contain idC.

Observe that it follows immediately from Proposition 2.8.7 that an initial

object in a category has no proper subobjects.

2.8.12 Subobjects in the category of sets
In Set, a monomorphism
is an injection, so a subobject is an equivalence class of injections. The
following sequence of statements are each easy to prove and together form a
precise description of the connection between subobjects and subsets in the
category of sets. Similar remarks can be made about other categories of sets
with structure, such as semigroups, monoids or posets.

In these statements, S is a set.

(a) Let O be a subobject of S.

(i) Any two injections m : A −→ S and n : B −→ S in O have the

same image; call the image I.

(ii) The inclusion i : I −→ S is equivalent to any injection in O, hence

is an element of O.

(iii) If j : J −→ S is an inclusion of a subset J into S that is in O,

then I = J and i = j.

(iv) Hence every subobject of S contains exactly one inclusion of a
subset of S into S, and that subset is the image of any element
of O.

(b) Let i : T −→ S be the inclusion of a subset T of S into S.

(i) Since i is injective, it is an element of a subobject of S.
(ii) Since the subobjects are equivalence classes of an equivalence

relation, they are disjoint, so i is not in two subobjects.

2.8 Monomorphisms and subobjects

51

(iii) Hence the subsets of S with their inclusion maps form a complete

set of class representatives for the subobjects of S.

Thus subobjects, given by a categorical deﬁnition, are not the same as
subsets, but each subset determines and is determined by a unique subobject.
Because of this close relationship, one frequently says, of objects A and
B in a category, ‘Let A be a subobject of B’, meaning that one has in mind
a certain equivalence class of monomorphisms that in particular contains a
monomorphism A (cid:41)−→ B. You should be aware that there may be many other
monomorphisms from A to B that are not in the equivalence class, just as
from any subset A of a set B there are generally many injective functions
from A to B other than the inclusion.

2.8.13 As a consequence of the properties of the subobject construction,
categorists take a diﬀerent attitude toward substructures such as subsets and
submonoids, as compared to many other mathematicians. For them, A is a
subobject or substructure of B if there is a monomorphism from A to B, and
the subobject is the equivalence class determined by that monomorphism.
For example, let Z denote the set of integers and R the set of real numbers.
In calculus classes, Z is a subset of R; an integer actually is a real number.
For the categorist, it suﬃces that there be a monic (injective) map from Z
to R.

That monic map is a kind of type conversion. (See [Reynolds, 1980] for
a more general view.) An integer need not actually be thought of as a real
number, but there is a standard or canonical way (translate this statement
as ‘a monic map’) to regard an integer as a real number. This mapping is
regarded by the categorist as an inclusion, even though in fact it may change
what the integer really is.

In a computer language, converting an integer to a real may increase
the storage allotted to it and change its representation. Something similar
happens in many approaches to the foundations of mathematics, where real
numbers are constructed from integers by a complicated process (Dedekind
cuts or Cauchy sequences), which results in an embedding of the integers in
the real numbers. Just as for computer languages, this embedding changes
the form of an integer: instead of whatever it was before, it is now a Dedekind
cut (or Cauchy sequence).

In traditional texts on foundations, this construction had to be modiﬁed
to replace the image of each integer by the actual integer, so that the in-
tegers were actually inside the real numbers. From the categorical point of
view, this is an unnecessary complication. This change results in replacing
a monomorphism Z −→ R by an equivalent monomorphism (one that deter-
mines the same subobject). From an operational point of view, the integers
behave the same way whether this change is made or not.

52

Categories

2.8.14 Categories and typing In category theory, the inclusion map is
usually made explicit. From the computing science point of view, category
theory is a very strongly typed language, more strongly typed than any com-
puter language. For example, the strict categorist will refer explicitly to the
inclusion map from the nonzero real numbers to the set of all real numbers
when talking of division. In a computer language this would correspond to
having two diﬀerent types, REAL and NONZERO REAL, set up in such a way
that you can divide a REAL only by a NONZERO REAL. To multiply a REAL by
a NONZERO REAL, the strong typing would require you to convert the latter
to a REAL ﬁrst.

To be sure, categorists themselves are not always so strict; but when they
are not strict they are aware of it. (Compare the comments in 1.2.2. Nor is
this discussion meant to imply that computer languages should have such
strict typing: rather, the intention is to illustrate the way category theory
handles types.)

2.8.15 Exercises

1. a. Show that if an arrow is a monomorphism in a category, it is a mono-
morphism in any subcategory it happens to be in.

b. Give an example showing that a monomorphism in a subcategory need
not be a monomorphism in the category containing the subcategory. (Hint:
Look at small ﬁnite categories.)

2. Show that if f : A −→ B and g : B −→ C are monomorphisms, so is g ◦ f .

3. Show that there are categories in which for some arrows f and g, g ◦ f is
a monomorphism but g is not. (Compare Proposition 2.8.6.)

4. Prove the statements in 2.8.12.

5. Show that if h : C −→ D is an isomorphism, then h ∼ idD (as deﬁned
in 2.8.9).

6. Show that an initial object has no proper subobjects.

7. Show that if A is a subobject of a terminal object and B is any object
then there is at most one arrow from B to A. Conclude that any arrow from
A is monic.

8. Find all the subobjects of the terminal object in each category:

a. Set.
b. The category of graphs and graph homomorphisms.
c. The category of monoids and monoid homomorphisms.
9.† Give an explicit description of the monomorphisms in Rel.

2.9 Other types of arrow

53

2.9 Other types of arrow

2.9.1 Epimorphisms Epimorphisms in a category are the same as mono-
morphisms in the dual category. So f : S −→ T is an epimorphism if for any
arrows g, h : T −→ X, g ◦ f = h ◦ f implies g = h. An epimorphism is said to
be epic or an epi, and may be denoted with a double-headed arrow, as in
f : S −→→ T .

2.9.2 Proposition A set function is an epimorphism in Set if and only
if it is surjective.

Proof. Suppose f : S −→ T is surjective, and g, h : T −→ X are two functions.
If g (cid:54)= h, then there is some particular element t ∈ T for which g(t) (cid:54)= h(t).
Since f is surjective, there is an element s ∈ S for which f (s) = t. Then
g(f (s)) (cid:54)= h(f (s)), so that g ◦ f (cid:54)= h ◦ f .

Conversely, suppose f is not surjective. Then there is some t ∈ T for
which there is no s ∈ S such that f (s) = t. Now deﬁne two functions g : T
−→ {0, 1} and h : T −→ {0, 1} as follows:

(i) g(x) = h(x) = 0 for all x in T except t.
(ii) g(t) = 0.
(iii) h(t) = 1.

Then g (cid:54)= h but g ◦ f = h ◦ f , so f is not an epimorphism.

2.9.3 In contrast to the situation with monomorphisms, epimorphisms in
categories of sets with structure are commonly not surjective. For example
the nonnegative integers and the integers are both monoids under addition,
and the inclusion function i is a homomorphism which is certainly not sur-
jective. However, it is an epimorphism.

Here is the proof: any homomorphism h whose domain is the integers is
determined completely by its value h(1). For positive m, m = 1 + 1 + · · · + 1,
so

h(m) = h(1 + 1 + · · · + 1) = h(1)h(1) · · · h(1)

where we write the operation in the codomain as juxtaposition. Also, h(−1)
is the inverse of h(1), since

h(1)h(−1) = h(−1)h(1) = h(−1 + 1) = h(0)

which must be the identity of the codomain. Since an element of a monoid
can have only one inverse, this means h(−1) is uniquely determined by h(1).
Then since every negative integer is a sum of −1’s, the value of h at every
negative integer is also determined by its value at 1.

54

Categories

Now suppose that g and h are two homomorphisms from the monoid of
integers into the same codomain. Then g and h are both determined by their
value at 1. Since 1 is a positive integer, this means that if g ◦ i = h ◦ i, then
g = h. Thus i is an epimorphism.

2.9.4 Proposition Let f : A −→ B and g : B −→ C. Then

(a) If f and g are epimorphisms, so is g ◦ f .
(b) If g ◦ f is an epimorphism, so is g.

Proof. This is the dual of Proposition 2.8.6.

2.9.5 In Set an arrow that is both monic and epic is bijective (Theo-
rems 2.8.3 and 2.9.2), and hence an isomorphism. In general, this need not
happen. One example is the inclusion of N in Z in Mon described in 2.9.3
(an inverse would also have to be an inverse in Set, but there isn’t one since
the inclusion is not bijective). An easier example is the arrow from C to D
in the category 2 in (2.1). It is both monic and epic (vacuously) but there is
no arrow from D to C so it is not an isomorphism because there is no arrow
in the category that could be its inverse.

2.9.6 An arrow f : A −→ B in a category is an isomorphism if it has an
inverse g : B −→ A which must satisfy both the equations g ◦ f = idA and
f ◦ g = idB. If it only satisﬁes the second equation, f ◦ g = idB, then f is a
left inverse of g and (as you might expect) g is a right inverse of f .

2.9.7 Deﬁnition Suppose f has a right inverse g. Then f is called a split
epimorphism (f is “split by g”) and g is called a split monomorphism.

A split epimorphism is indeed an epimorphism: if h ◦ f = k ◦ f and f has
a right inverse g, then h = h ◦ f ◦ g = k ◦ f ◦ g = k, which is what is required
for f to be an epimorphism. A dual proof shows that a split monomorphism
is a monomorphism.

Using the usual axioms of set theory, every surjection in Set is a split
epimorphism. For if f : A −→ B, then choose, for each b ∈ B, some element
a ∈ A such that f (a) = b. The existence of such an a is guaranteed by
surjectivity. Deﬁne g(b) to be a. Then f (g(b)) = f (a) = b for any b ∈ B, so
f ◦ g = idB.

The so-called axiom of choice is exactly what is required to make all those
generally inﬁnitely many choices. And in fact, one possible formulation of the
axiom of choice is that every epimorphism split.

2.9 Other types of arrow

55

Epimorphisms in other categories may not be split. The function that
includes the monoid of nonnegative integers on addition in the monoid of
all the integers on addition, which we mentioned in 2.9.3, certainly does not
have a right inverse in the category of monoids, since it does not have a right
inverse in the category of sets. There are plenty of examples of epimorphisms
of monoids which are surjective which have no right inverse in the category
of monoids, although of course they do in the category of sets (Exercise 2).
Unlike epis, which always split in the category of sets, monics in Set do
not always split. Every arrow out of the empty set is monic and, save for
the identity of ∅ to itself, is not split. On the other hand, every monic with
nonempty source does split. We leave the details to you.

2.9.8 Hom sets The elementary categorical deﬁnitions given in the last
section and this one can all be phrased in terms of hom set. In any category,
Hom(A, B) is the set of arrows with source A and target B.

Thus a terminal object 1 satisﬁes the requirement that Hom(A, 1) is a
singleton set for every object A, and an initial object 0 satisﬁes the dual
requirement that Hom(0, A) is always a singleton. And Hom(1, A) is the set
of constants (global elements) of A.

2.9.9 If f : B −→ C, f induces a set function

Hom(A, f ) : Hom(A, B) −→ Hom(A, C)

deﬁned by composing by f on the left: for any g ∈ Hom(A, B), that is, for
any g : A −→ B, Hom(A, f )(g) = f ◦ g, which does indeed go from A to C.
(Compare Exercise 1 of Section 1.2.)

Similarly, for any object D, f : B −→ C induces a set function

Hom(f, D) : Hom(C, D) −→ Hom(B, D)

(note the reversal) by deﬁning Hom(f, D)(h) = h ◦ f for h ∈ Hom(C, D).

In terms of these functions, we can state this proposition, which we leave

to you to prove.

2.9.10 Proposition An arrow f : B −→ C in a category

(i) is a monomorphism if and only if Hom(A, f ) is injective for every

object A;

(ii) is an epimorphism if and only if Hom(f, D) is injective (!) for every

object D;

(iii) is a split monomorphism if and only if Hom(f, D) is surjective for

every object D;

56

Categories

(iv) is a split epimorphism if and only if Hom(A, f ) is surjective for every

object A;

(v) is an isomorphism if and only if any one of the following equivalent

conditions holds:

(a) it is both a split epi and a mono;
(b) it is both an epi and a split mono;
(c) Hom(A, f ) is bijective for every object A;
(d) Hom(f, A) is bijective for every object A.

Although many categorical deﬁnitions can be given in terms of hom sets, no
categorical deﬁnition must be; in fact, some mathematicians consider category
theory to be a serious alternative to set theory as a foundation for mathematics
(see many works of Lawvere, including [1963] and [1966] as well as [McLarty,
1989]) and for that purpose (which is not our purpose, of course), deﬁnition in
terms of hom sets or any other sets must be avoided.

2.9.11 Discussion Categorical deﬁnitions, as illustrated in the simple ideas
of Sections 2.7, 2.8 and 2.9, provide a method of abstract speciﬁcation which
has proved very useful in mathematics. They have, in particular, clariﬁed
concepts in many disparate branches of mathematics and provided as well a
powerful uniﬁcation of concepts across these branches.

The method of categorical deﬁnition is close in spirit to the modern atti-
tude of computing science that programs and data types should be speciﬁed
abstractly before being implemented and that the speciﬁcation should be
kept conceptually distinct from the implementation. We believe that the
method of categorical deﬁnition is a type of abstract speciﬁcation which is
suitable for use in many areas of theoretical computing science. This is one
of the major themes of this book.

When a category C is a category of sets with structure, with the arrows
being functions which preserve the structure, a categorical deﬁnition of a
particular property does not involve the elements (in the standard sense of
set theory) of the structure. Such deﬁnitions are said to be element-free,
and that has been regarded as a great advantage of category theory.

Nevertheless, as we have seen, some deﬁnitions can be phrased in terms
of variable elements. This allows us the option of using familiar modes of
thinking about things in terms of elements even in general categories. In
the case of the deﬁnition of monomorphism 2.8.2, the deﬁnition phrased in
terms of variable elements is identical with the deﬁnition in Set. On the
other hand, an epimorphism f (see 2.9.1) is a variable element with the
property that any two diﬀerent arrows out of its target must have diﬀerent
values at f . In some sense it is a variable element with a lot of variation.

2.9 Other types of arrow

57

This is an example of a situation where the variable element point of view
is not very familiar.

The idea of variable element has much in common with the way mathe-
maticians and physicists once thought of variable quantities. Perhaps thirty
years from now the variable element idea will be much more pervasive and
the idea that an epimorphism is an element with a lot of variation will be
the natural way to describe it.

2.9.12 Exercises

1. Show that a surjective monoid homomorphism is an epimorphism.

2. Let Zn denote the monoid of integers (mod n) with addition (mod n) as
operation. Show that the map φ : Z4 −→ Z2 that takes 0 and 2 to 0 and 1
and 3 to 1 is a surjective monoid epimorphism and is not split.

3. Let M be a monoid.

a. Show that if M is ﬁnite then an element is a monomorphism in C(M )
if and only if it is an epimorphism in C(M ) if and only if it is an isomorphism
in C(M ).

b. Give an example showing that the assumption of ﬁniteness in (a)

cannot be relaxed.

4. Show that in the category C(P ) determined by a poset P , the only split
epis or split monos are the identity arrows.

5. Show that if h has a left inverse g, then h ◦ g is a split idempotent (see
Exercise 10 of Section 2.7).

6. Prove Proposition 2.9.10. (For (iii), set D = B.)
7.† Show that in the category of graphs and graph homomorphism, a homo-
morphism f : G −→ H has any of the following properties if and only if both
f0 : G0 −→ H0 and f1 : G1 −→ H1 (which are set functions) have the property
in Set:

(i) epic;
(ii) monic;
(iii) an isomorphism.

8. An epimorphism f : A −→ B in a category is extremal if whenever f =
m ◦ g where m is monic implies m is an isomorphism.

a. Show that a split epi is extremal.
b. Let C be a category in which every arrow that is both monic and epic

is an isomorphism. Show that every epimorphism in C is extremal.

58

Categories

2.10 Factorization systems

It is a familiar fact that every function in the category of sets can be fac-
tored as an epimorphism (surjection) followed by a monomorphism (injec-
tion). Similarly, every homomorphism in the category of abelian groups can
be factored as an epimorphism followed by a monomorphism. The prop-
erties of these factorizations were abstracted early in the days of category
theory, where they were known as bicategory structures. Under the name
factorization system, they have a number of uses in category theory.

2.10.1 Deﬁnition A factorization system in a category C consists of
two subclasses E and M of the arrows of C subject to the conditions

FS—-1 If I is the class of isomorphisms, then M ◦ I ⊆ M and I ◦ E ⊆ E .
FS—-2 Every arrow f in C factors as f = m ◦ e with m ∈ M and e ∈ E .
FS—-3 In any commutative square

A

B(cid:45)(cid:45)e

f

g

(cid:63)
(cid:45)
C

(cid:63)
D(cid:45)

m

with e ∈ E and m ∈ M , there is a unique h : B −→ C such that
h ◦ e = f and m ◦ h = g.

The last condition is referred to as the “diagonal ﬁll-in”. If (as is the case
in many examples) either every arrow in M is monic or every arrow in E
is epic, then the uniqueness requirement in this condition may be omitted
(Exercise 2).

In discussing categories with factorization systems the usual convention
is to denote an element of M with a tailed arrow and an element of E with a
double-headed arrow. This may conﬂict with the conventions described after
Deﬁnitions 2.8.2 and 2.9.1.

2.10.2 Example
In Set, the class E of epimorphisms and the class M of
monomorphisms constitute a factorization system. In many categories of al-
gebraic structures (including monoids), the class E of regular epimorphisms
(deﬁned in Section 9.4.3) and the class M of monomorphisms constitute a
factorization system. In the category of monoids and monoid homomorph-
isms, the class of all epis and all monos is not a factorization system.

In the rest of this section, we assume E and M constitute a factorization

system.

2.10.3 Proposition The classes E and M are each closed under compo-
sition.

2.10 Factorization systems

59

Proof. Suppose m1 : A (cid:41)−→ D and m2 : D (cid:41)−→ C with m1 and m2 in M .
Factor m2 ◦ m1 = m ◦ e with m ∈ M and e ∈ E . The diagonal ﬁll-in in the
square

A
(cid:63)

m1

(cid:63)
(cid:45)
D

B(cid:45)(cid:45)e
(cid:63)

m

(cid:63)

C(cid:45)

A

id

(cid:63)
(cid:45)
A

B(cid:45)(cid:45)e

f

(cid:63)
D(cid:45)

m2
is an arrow f : B −→ D such that f ◦ e = m1 and m2 ◦ f = m. The diagonal
ﬁll-in in the square

m1
is a map g : B −→ A such that g ◦ e = id and m1 ◦ g = f . Since m ◦ e ◦
g = m2 ◦ m1 ◦ g = m2 ◦ f = m = m ◦ id and e ◦ g ◦ e = e = id ◦ e both the
identity and e ◦ g supply a diagonal ﬁll-in in the square

A

e

(cid:63)(cid:63)
(cid:45)
B

B(cid:45)(cid:45)e
(cid:63)

m

(cid:63)

C(cid:45)

m

and hence, by uniqueness, are equal. This shows that e is an isomorphism
and hence that m2 ◦ m1 = m ◦ e ∈ M . The argument for E is dual.

2.10.4 Proposition If f : A −→ B factors as A

−−→→ C(cid:48) m(cid:48)
e(cid:48)

as A
g ◦ e = e(cid:48) and m(cid:48) ◦ g = m; moreover g is an isomorphism.

(cid:41)−−−→ B then there is a unique arrow g : C −→ C(cid:48) such that

e
−−→→ C

m

(cid:41)−−→ B and also

Proof. The arrow g is the diagonal ﬁll-in in the square

A

e(cid:48)

(cid:63)(cid:63)
(cid:45)
C(cid:48)

C(cid:45)(cid:45)e
(cid:63)

m

(cid:63)
B(cid:45)

m(cid:48)

60

Categories

To see that g is an isomorphism, we transpose the square to get a map
g(cid:48) : C(cid:48) −→ C such that g(cid:48) ◦ e(cid:48) = e and m ◦ g(cid:48) = m(cid:48). Then we note that these
equations imply that both the identity and g(cid:48) ◦ g ﬁll in the square

A

e

(cid:63)(cid:63)
(cid:45)
C

C(cid:45)(cid:45)e
(cid:63)

m

(cid:63)
B(cid:45)

m

and the uniqeness of the diagonal ﬁll-in forces g(cid:48) ◦ g = id and similarly g ◦
g(cid:48) = id.

2.10.5 Proposition Suppose f : C −→ D satisﬁes the condition that for
all e : A −→→ B in E , any commutative square
B(cid:45)(cid:45)e

A

(cid:63)
C

(cid:63)
D(cid:45)

f

has a unique diagonal ﬁll-in. Then f ∈ M . Dually, if g : A −→ B satisﬁes
the condition that for all m : C (cid:41)−→ D in M , any commutative square

A

B(cid:45)f

(cid:63)
(cid:45)
C

(cid:63)
D(cid:45)

m

has a unique diagonal ﬁll-in. Then g ∈ E .

Proof. Factor f as C

e

−→→ A

m

(cid:41)−−→ D. From the diagonal ﬁll-in in the square

C

A(cid:45)(cid:45)e

id

m

(cid:63)
C

(cid:63)
D(cid:45)

f

we get a map g : A −→ C such that g ◦ e = id and f ◦ g = m. Then from
e ◦ g ◦ e = e and m ◦ e ◦ g = f ◦ g = m we see that both the identity and

e ◦ g ﬁll in the diagonal of

2.10 Factorization systems

61

C

e

(cid:63)(cid:63)
(cid:45)
A

A(cid:45)(cid:45)e
(cid:63)

m

(cid:63)

C(cid:45)

m

The uniqueness of the diagonal ﬁll-in then implies that e is an isomorphism,
whence f = m ◦ e ∈ M by FS–1.

2.10.6 Corollary Every isomorphism is in E ∩ M .

2.10.7 Proposition Suppose every arrow in E is an epimorphism. Then
g ◦ f ∈ M implies that f ∈ M .

f

−−→ D

g

−−→ E is in M . Suppose we have a

Proof. Suppose the composite C
commutative square

A

h

(cid:63)
C

The diagonal ﬁll-in in the square

B(cid:45)(cid:45)e

k
(cid:63)
D(cid:45)

f

A

B(cid:45)(cid:45)e

h

(cid:63)
(cid:45)
C

g ◦ k

(cid:63)
E(cid:45)

g ◦ f

provides a map l : B −→ C such that l ◦ e = h. Then e can be cancelled on
the right of f ◦ l ◦ e = f ◦ h = k ◦ e to conclude that f ◦ l = k. If l(cid:48) were
another choice, e can be cancelled from l ◦ e = l(cid:48) ◦ e.

2.10.8 Proposition Suppose E /M is a factorization system on the cat-
egory C . Suppose f : A −→ B is an arrow of C such that for all m : C −→ D

62

Categories

in M , and any commutative square

A

g

B(cid:45)f

h
(cid:63)
D(cid:45)

(cid:63)
C

m

there is a diagonal ﬁll-in (not even assumed unique) l : B −→ C making both
triangles commute. Then f ∈ E .

Proof. Factor f as A

e
−→ C

m

−−→ B with m ∈ M and e ∈ E . In the diagram

B(cid:45)f

A

e

id
(cid:63)
B(cid:45)

(cid:63)
C

m

the diagonal ﬁll-in property of f implies the existence of an arrow l : B −→ C
such that l ◦ f = e and m ◦ l = id. The diagram

A

e

C(cid:45)e

m

(cid:63)
C

(cid:63)
B(cid:45)

m

has the identity as diagonal ﬁll-in. But also l ◦ m ◦ e = l ◦ f = e and m ◦ l ◦
m = m. Thus the uniqeness of the diagonal ﬁll-in (which is assumed to hold
the top arrow is in E and the bottom arrow is in M ) forces l ◦ m = id which
implies that m is an isomorphism and then f = m ◦ e ∈ E .

Of course, the dual property characterizes the arrows of M .
More properties of factorization systems will be explored in Chapter 9.

2.10 Factorization systems

63

2.10.9 Exercises

1. Show that every category has a factorization system in which E consists
of all arrows and M of all isomorphisms. (Switching the roles of E and
M gives another one. Thus every category in which not every arrow is an
isomorphism has at least two distinct factorization systems.)

2. Let (E , M ) be a factorization system. Show that if either every arrow
in M is monic or every arrow in E is epic then the requirement that h be
unique in FS–3 of Deﬁnition 2.10.1 may be omitted.

3. Show that the class E of epimorphisms and M of monomorphisms con-
stitute an epi-mono factorization system in Set.

4. Let Z be the monoid of all integers on addition, and N the monoid of all
nonnegative integers on addition. Let i : N −→ Z be inclusion (which is both
monic and epic, see Section 2.9.3). Show that the diagram

N

Z(cid:45)i

id

(cid:63)
N

id
(cid:63)
Z(cid:45)

i

commutes but has no diagonal ﬁll-in. Hence the set E of all epimorphisms
and the set M of all monomorphisms do not constitute a factorization system
in the category of monoids.

3
Functors

A functor F from a category C to a category D is a graph homomorphism
which preserves identities and composition. It plays the same role as monoid
homomorphisms for monoids and monotone maps for posets: it preserves
the structure that a category has. Functors have another signiﬁcance, how-
ever: since one sort of thing a category can be is a mathematical workspace
(see Preface), many of the most useful functors used by mathematicians are
transformations from one type of mathematics to another.

Less obvious, but perhaps more important, is the fact that many cate-
gories that are mathematically interesting appear as categories whose objects
are a natural class of functors into the category of sets. This point of view
will be explored in the chapters on sketches.

The ﬁrst three sections deﬁne functors, give examples and describe some
properties functors may have. Section 3.4 deﬁnes the concept of equivalence
of categories, which captures the idea that two categories are the same from
the categorical point of view. The last section concerns quotients of cate-
gories, which have quotients of monoids as special cases. This concept is
used only in the chapters on sketches (and in 4.1.13, which itself is used only
for sketches).

3.1 Functors

A functor is a structure-preserving map between categories, in the same
way that a homomorphism is a structure-preserving map between graphs or
monoids. Here is the formal deﬁnition.

3.1.1 Deﬁnition A functor F : C −→ D is a pair of functions F0 : C0
−→ D0 and F1 : C1 −→ D1 for which

F–1 If f : A −→ B in C , then F1(f ) : F0(A) −→ F0(B) in D.
F–2 For any object A of C , F1(idA) = idF0(A).
F–3 If g ◦ f is deﬁned in C , then F1(g) ◦ F1(f ) is deﬁned in D and F1(g ◦

f ) = F1(g) ◦ F1(f ).

65

66

Functors

By F–1, a functor is in particular a homomorphism of graphs. Following
the practice for graph homomorphisms, the notation is customarily over-
loaded (see 1.4.2): if A is an object, F (A) = F0(A) is an object, and if f
is an arrow, F (f ) = F1(f ) is an arrow. The notation for the constituents
F0 : C0 −→ D0 and F1 : C1 −→ D1 is not standard, and we will use it only for
emphasis.

3.1.2 Example It is easy to see that a monoid homomorphism f : M
−→ N determines a functor from C(M ) to C(N ) as deﬁned in 2.3.12. On
objects, a homomorphism f must take the single object of C(M ) to the
single object of C(N ), and F–1 is trivially veriﬁed since all arrows in C(M )
have the same domain and codomain and similarly for C(N ). Then F–2
and F–3 say precisely that f is a monoid homomorphism. Conversely, every
functor is determined in this way by a monoid homomorphism.

3.1.3 Example Let us see what a functor from C(S, α) to C(T, β) must
be when (S, α) and (T, β) are posets as in 2.3.1. It is suggestive to write both
relations α and β as ‘≤’ and the posets simply as S and T . Then there is
exactly one arrow from x to y in S (or in T ) if and only if x ≤ y; otherwise
there are no arrows from x to y.

Let f : S −→ T be the functor. F–1 says if there is an arrow from x to y,

then there is an arrow from f (x) to f (y); in other words,

if x ≤ y then f (x) ≤ f (y)

Thus f is a monotone map (see 2.4.2). F–2 and F–3 impose no additional
conditions on f because they each assert the equality of two speciﬁed arrows
between two speciﬁed objects and in a poset as category all arrows between
two objects are equal.

3.1.4 Example If C is a category, the functor

P1 : C × C −→ C

(see 2.6.6) which takes an object (C, D) to C and an arrow (f, g) : (C, D)
−→ (C(cid:48), D(cid:48)) to f is called the ﬁrst projection. There is an analogous second
projection functor P2 taking an object or arrow to its second coordinate.

3.1.5 Example Let 2 + 2 be the category that can be pictured as

0 −→ 1

1(cid:48) −→ 2

with no other nonidentity arrows, and the category 3 the one that looks like

3.1 Functors

67

0

(cid:64)

(cid:64)

(cid:64)(cid:82)

2

1(cid:45)
(cid:161)

(cid:161)

(cid:161)(cid:170)

(3.1)

Deﬁne the functor F : 2 + 2 −→ 3 to take 0 to 0, 1 and 1(cid:48) to 1, and 2 to 2.
Then what it does on arrows is forced.

Note that the image of F includes all of D except the composite arrow
from 0 −→ 2. This example shows that the image of a functor need not be a
subcategory of the codomain category.

3.1.6 The category of categories The category Cat has all small cat-
egories as objects and all functors between such categories as arrows. The
composite of functors is their composite as graph homomorphisms: if F : C
−→ D and G : D −→ E , then G ◦ F : C −→ E satisﬁes G ◦ F (C) = G(F (C))
for any object C of C , and G ◦ F (f ) = G(F (f )) for any arrow f of C . Thus
(G ◦ F )i = Gi ◦ Fi for i = 0, 1.

We note that the composition circle is usually omitted when composing

functors so that we write GF (C) = G(F (C)).

It is sometimes convenient to refer to a category CAT which has all small
categories and ordinary large categories as objects, and functors between
them. Since trying to have CAT be an object of itself would raise delicate
foundational questions, we do not attempt here a formal deﬁnition of CAT.

3.1.7 Example The inclusion map of a subcategory is a functor. As we
pointed out in 2.8.13, the categorical point of view does not require that the
object and arrows of a subcategory actually be objects and arrows of the
bigger category, only that there be a monomorphism from the subcategory
to the category. For example, Set is a subcategory of Rel: the monomorphic
functor takes every set to itself and each function f : S −→ T to its graph
{(s, t) | t = f (s)}, which is indeed a relation from S to T .

This approach has the strange result that two diﬀerent categories can

each be regarded as subcategories of the other one (Exercises 8 and 9).

3.1.8 Underlying functors Forgetting some of the structure in a cate-
gory of structures and structure-preserving functions gives a functor called an
underlying functor or forgetful functor. The functor U : Mon −→ Sem
which embeds the category of monoids into the category of semigroups by
forgetting that a monoid has an identity is an example of an underlying
functor.

68

Functors

Another example is the functor which forgets all the structure of a semi-
group. This is a functor U : Sem −→ Set. There are lots of semigroups with
the same set of elements; for example, the set {0, 1, 2} is a semigroup on
addition (mod 3) and also a diﬀerent semigroup on multiplication (mod 3).
The functor U applied to these two diﬀerent semigroups gives the same set,
so U is not injective on objects, in contrast to the forgetful functor from
monoids to semigroups.

We will not give a formal deﬁnition of underlying functor. It is reasonable
to expect any underlying functor U to be faithful (see 3.3.2 below) and that
if f is an isomorphism and U (f ) is an identity arrow then f is an identity
arrow.

3.1.9 Example A small graph has two underlying sets: its set of nodes
and its set of arrows. Thus there is an underlying functor U : Grf −→ Set ×
Set for which for a graph G , U (G ) = (G0, G1); an arrowset functor A : Grf
−→ Set which takes a graph to its set of arrows and a graph homomorphism
to the corresponding function from arrows to arrows; and a similarly deﬁned
nodeset functor N : Grf −→ Set which takes a graph to its set of nodes.

3.1.10 Example If you forget you can compose arrows in a category and
you forget which arrows are the identities, then you have remembered only
that the category is a graph. This gives an underlying functor U : Cat −→
Grf , since every functor is a graph homomorphism although not vice versa.
As for graphs, there are also set-of-objects and set-of-arrows functors
O : Cat −→ Set and A : Cat −→ Set which take a category to its set of
objects and set of arrows respectively, and a functor to the appropriate set
map.

3.1.11 Example In 2.6.10, we described the notion of a slice category
C /A based on a category C and an object A. An object is an arrow B −→ A
and an arrow from f : B −→ A to g : C −→ A is an arrow h : B −→ C for
which

g ◦ h = f

There is a functor U : C /A −→ C that takes the object f : B −→ A to B
and the arrow h from B −→ A to C −→ A to h : B −→ C. This is called the
underlying functor of the slice. In the case that C = Set, an object T −→ S of
Set/S for some set S is an S-indexed object, and the eﬀect of the underlying
functor is to forget the indexing.

3.1.12 Free functors The free monoid functor from Set to the cate-
gory of monoids takes a set A to the free monoid F (A), which is the Kleene

3.1 Functors

69

closure A∗ with concatenation as operation (see 2.3.9), and a function f : A
−→ B to the function F (f ) = f ∗ : F (A) −→ F (B) deﬁned in 2.5.7.

To see that the free monoid functor is indeed a functor it is necessary to
show that if f : A −→ B and g : B −→ C, then F (g ◦ f ) : F (A) −→ F (C) is
the same as F (g) ◦ F (f ), which is immediate from the deﬁnition, and that
it preserves identity arrows, which is also immediate.

The Kleene closure is itself a functor from Set to Set, taking A to A∗
and f to f ∗. It is the composite U ◦ F of the underlying functor U : Mon
−→ Set and the free functor F : Set −→ Mon, but of course it can be deﬁned
independently of U and F .

3.1.13 Example The free category on a graph is also the object part of
a functor F : Grf −→ Cat. What it does to a graph is described in 2.6.16.
Suppose φ : G −→ H is a graph homomorphism. The objects of the free
category on a graph are the nodes of the graph, so it is reasonable to
deﬁne F (φ)0 = φ0. Now suppose (fn, fn−1, . . . , f1) is a path, that is, an
arrow, in F (G ). Since functors preserve domain and codomain, we can de-
ﬁne F (φ)1(fn, fn−1, . . . , f1) to be (φ1(fn), φ1(fn−1), . . . , φ1(f1)) and know we
get a path in F (H ). That F preserves composition of paths is also clear.

3.1.14 The map-lifting property The free category functor F : Grf
−→ Cat and also other free functors, such as the free monoid functor (3.1.12),
have a map lifting property called its universal mapping property which
will be seen in Section 13.2 as the deﬁning property of freeness. We will
describe the property for free categories since we use it later. The free monoid
case is done in detail in Proposition 13.1.2.

Let G be a graph and F (G ) the free category generated by G . There is
a graph homomorphism with the special name ηG : G −→ U (F (G )) which
includes a graph G into U (F (G )), the underlying graph of the free category
F (G ). The map (ηG )0 is the identity, since the objects of F (G ) are the nodes
of G . For an arrow f of G , (ηG )1(f ) is the path (f ) of length one. This is
an inclusion arrow in the generalized categorical sense of 2.8.13, since f and
(f ) are really two distinct entities.

3.1.15 Proposition Let G be a graph and C a category. Then for every
graph homomorphism h : G −→ U (C ), there is a unique functor (cid:98)h : F (G )
−→ C with the property that U ((cid:98)h) ◦ ηG = h.
Proof. If () is the empty path at an object a, we set (cid:98)h() = ida. For an
object a of F (G ) (that is, node of G ), deﬁne (cid:98)h(a) = h(a). And for a path
(an, an−1, . . . , a1), (cid:98)h is ‘map h’:

(cid:98)h(an, an−1, . . . , a1) = (h(an), h(an−1), . . . , h(a1))

70

Functors

As noted in 2.1.1, there is a unique empty path for each node a of G .
Composing the empty path at a with any path p from a to b gives p again,
and similarly on the other side. That is why the program returns ida for the
empty path at a.

3.1.16 Powerset functors Any set S has a powerset PS, the set of all
subsets of S. There are three diﬀerent functors F for which F0 takes a set
to its powerset; they diﬀer on what they do to arrows. One of them is fun-
damental in topos theory; that one we single out to be called the powerset
functor.

If f : A −→ B is any set function and C is a subset of B, then the inverse
image of C, denoted f −1(C), is the set of elements of A which f takes into
C: f −1(C) = {a ∈ A | f (a) ∈ C}. Thus f −1 is a function from PB to PA.
Note that for a bijection f , the symbol f −1 is also used to denote the
inverse function. Context makes it clear which is meant, since the input to
the inverse image function must be a subset of the codomain of f , whereas
the input to the actual inverse of a bijection must be an element of the
codomain.

3.1.17 Deﬁnition The powerset functor P : Setop −→ Set takes a set
S to the powerset PS, and a set function f : A −→ B (that is, an arrow from
B to A in Setop) to the inverse image function f −1 : PB −→ PA.

Although we will continue to use the notation f −1, it is denoted f ∗ in

much of the categorical literature.

To check that P is a functor requires showing that id−1

A = idPA and
that if g : B −→ C, then (g ◦ f )−1 = f −1 ◦ g−1, where both compositions
take place in Set.

3.1.18 A functor F : C op −→ D is also called a contravariant functor
from C to D. As illustrated in the preceding deﬁnition, the functor is of-
ten deﬁned in terms of arrows of C rather than of arrows of C op. Opposite
categories are most commonly used to provide a way of talking about con-
travariant functors as ordinary (covariant) functors: the opposite category
in this situation is a purely formal construction of no independent interest
(see 2.6.9).

3.1.19 The other two functors which take a set to its powerset are both
covariant. The direct or existential image functor takes f : A −→ B to the
function f∗ : PA −→ PB, where f∗(A0) = {f (x) | x ∈ A0}, the set of values
of f on A0. The universal image functor takes A0 to those values of f
which come only from A0: formally, it takes f : A −→ B to f! : PA −→ PB,
with

3.1 Functors

71

f!(A0) = {y ∈ B | f (x) = y implies x ∈ A0} = {y ∈ B | f −1({y}) ⊆ A0}

3.1.20 Hom functors Let C be a category with an object C and an
arrow f : A −→ B. In 2.9.9, we deﬁned the function Hom(C, f ) : Hom(C, A)
−→ Hom(C, B) by setting Hom(C, f )(g) = f ◦ g for every g ∈ Hom(C, A),
that is for g : C −→ A. We use this function to deﬁne the covariant hom
functor Hom(C, −) : C −→ Set as follows:

HF–1 Hom(C, −)(A) = Hom(C, A) for each object A of C ;
HF–2 Hom(C, −)(f ) = Hom(C, f ) : Hom(C, A) −→ Hom(C, B) for f : A −→

B.

The following calculations show that Hom(C, −) is a functor. For an
object A, Hom(C, idA) : Hom(C, A) −→ Hom(C, A) takes an arrow f : C
−→ A to idA ◦ f = f ; hence Hom(C, idA) = idHom(C,A). Now suppose f : A
−→ B and g : B −→ D. Then for any arrow k : C −→ A,
(cid:181)

(cid:182)

(cid:182)

(cid:181)

Hom(C, g) ◦ Hom(C, f )

(k) = Hom(C, g)

Hom(C, f )(k)

= Hom(C, g)(f ◦ k)
= g ◦ (f ◦ k)
= (g ◦ f ) ◦ k
= Hom(C, g ◦ f )(k)

In terms of variable elements, Hom(C, f ) takes the variable elements of
A with parameter set C to the variable elements of B with parameter set C.

There is a distinct covariant hom functor Hom(C, −) for each object C. In this
expression, C is a parameter for a family of functors. The argument of each
of these functors is indicated by the dash. An analogous deﬁnition in calculus
would be to deﬁne the function which raises a real number to the nth power as
f (−) = (−)n (here n is the parameter). One diﬀerence in the hom functor case
is that the hom functor is overloaded and so has to be deﬁned on two diﬀerent
kinds of things: objects and arrows.

3.1.21 Deﬁnition For a given object D, the contravariant hom func-
tor

Hom(−, D) : C op −→ Set

is deﬁned for each object A by

Hom(−, D)(A) = Hom(A, D)

and for each arrow f : A −→ B,

Hom(−, D)(f ) = Hom(f, D) : Hom(B, D) −→ Hom(A, D)

Thus if g : B −→ D, Hom(f, D)(g) = g ◦ f .

72

Functors

3.1.22 Deﬁnition The two-variable hom functor

Hom(−, −) : C op × C −→ Set

takes a pair (C, D) of objects of C to Hom(C, D), and a pair (f, g) of arrows
with f : C −→ A and g : B −→ D to

Hom(f, g) : Hom(A, B) −→ Hom(C, D)

where for h : A −→ B,

Hom(f, g)(h) = g ◦ h ◦ f

which is indeed an arrow from C to D.

In this case we also use the product of categories as a formal construction
to express functors of more than one argument. From the categorical point
of view, a functor always has one argument, which as in the present case
might well be an object in a product category (an ordered pair).

3.1.23 Exercises

1. Show that in the deﬁnition of functor, the clause ‘F1(g) ◦ F1(f ) is deﬁned
in D’ can be omitted.

2. Describe the initial and terminal objects in the category of categories and
functors.

3. Prove that the existential and universal image functors of 3.1.19 are func-
tors.

4. a. Prove that a functor is a monomorphism in the category of categories if
and only if it is injective on both objects and arrows. (Compare Exercise 7(ii)
of Section 2.9. The corresponding statement for epimorphisms is not true
(Section 3.3).)

b. Prove that the functor U : Mon −→ Sem described in 3.1.8 is a mono-

morphism.

5. Given a semigroup S, construct a monoid M = S ∪ {e}, using a new
element e not in S and diﬀerent for each semigroup S. For example, you
could take e = {S}. The multiplication in M is deﬁned this way:

(i) xy is the product in S if both x and y are in S.

3.1 Functors

73

(ii) xe = ex = x for all x ∈ M .

M is denoted S1 in the semigroup literature. Show that

a. S1 is a monoid (note that if S is already a monoid, S1 is too but with

a new identity element);

b. there is a functor F : Sem −→ Mon which takes each semigroup S to
S1 and each semigroup homomorphism f : S −→ T to a monoid homomorph-
ism f 1 : S1 −→ T 1 which is the same as f on S and which takes the added
element to the added element;

c. F is a monomorphism in Cat.

6. Let U : Mon −→ Set be the underlying set functor, and F : Set −→ Mon
the free monoid functor. For every set A and monoid M , construct a function

β : HomSet(A, U (M )) −→ HomMon(F (A), M )

by deﬁning

β(f )(a1a2 · · · an) = f (a1)f (a2) · · · f (an)

(the right side is the product in M ) for f : A −→ U (M ). Show that β is a
bijection.

7. Let U : Mon −→ Sem be the functor of 3.1.7 and F : Sem −→ Mon the
functor of Exercise 5. Deﬁne a function

γ : HomSem(S, U (M )) −→ HomMon(F (S), M )

by γ(h)(s) = h(s) if s ∈ S and γ(h)(eS) = 1 if eS is the new element added
to S to construct F (S), where 1 is the identity element of M . Show that γ
has the claimed codomain and is a bijection. (Compare Exercise 6.)

8. Show that each of Mon and Sem is a subcategory of the other.

9. Show that Set and Pfn are each subcategories of the other. (Hint: To
construct a monic functor from Pfn to Set, take each set A to the set
A ∪ {A}, and a partial function f : A −→ B to the full function f (cid:48) for which
f (cid:48)(x) = f (x) if f (x) is deﬁned, and f (cid:48)(x) = B otherwise.)
10.† Let A be a category. Show that A is discrete (see Exercise 11 of Sec-
tion 2.7) if and only if every set function F : A0 −→ B0, where B is any
category, is the object part of a unique functor from A to B.
11.† A category B is indiscrete if every set function F : A0 −→ B0, where
A is any category, is the object part of a unique functor from A to B. Give
a deﬁnition of ‘indiscrete’ in terms of the objects and arrows of B.

74

Functors

3.2 Actions

In this section, we discuss set-valued functors as a natural generalization of
ﬁnite state machines. This section is referred to only in Chapter 12 and in a
few scattered examples. Set-valued functors also have theoretical importance
in category theory because of the Yoneda Lemma (Section 4.5).

3.2.1 Monoid actions Let M be a monoid with identity 1 and let S be
a set. An action of M on S is a function α : M × S −→ S for which

A–1 α(1, s) = s for all s ∈ S.
A–2 α(mn, s) = α(m, α(n, s)) for all m, n ∈ M and s ∈ S.

It is customary in mathematics to write ms for α(m, s); then the preced-

ing requirements become

A(cid:48)–1 1s = s for all s ∈ S.
A(cid:48)–2 (mn)s = m(ns) for all m, n ∈ M and s ∈ S.

When actions are written this way, S is also called an M -set. The same
syntax ms for m ∈ M and s ∈ S is used even when diﬀerent actions are
involved. This notation is analogous to (and presumably suggested by) the
notation cv for scalar multiplication, where c is a scalar and v is a vector.
It is useful to think of the set S as a state space and the elements of M

as acting to induce transitions from one state to another.

3.2.2 Deﬁnition Let M be a monoid with actions on sets S and T . An
equivariant map from S to T is a function φ : S −→ T with the property
that mφ(s) = φ(ms) for all m ∈ M and s ∈ S. The identity function is an
equivariant map and the composite of two equivariant maps is equivariant.
This means that for each monoid M , monoid actions and equivariant maps
form a category M –Act.

3.2.3 Actions as functors Let α be an action of a monoid M on a set
S. Let C(M ) denote the category determined by M as in 2.3.12. The action
α determines a functor Fα : C(M ) −→ Set deﬁned by:

AF–1 Fα(∗) = S.
AF–2 Fα(m) = s (cid:55)→ α(m, s) for m ∈ M and s ∈ S.

This observation will allow us to generalize actions to categories in 3.2.6.

3.2 Actions

75

3.2.4 Example One major type of action by a monoid is the case when
the state space is a vector space and M is a collection of linear transforma-
tions closed under multiplication. However, in that case the linear structure
(the fact that states can be added and multiplied by scalars) is extra struc-
ture which the deﬁnition above does not require. Our deﬁnition also does not
require that there be any concept of continuity of transitions. Thus, the def-
inition is very general and can be regarded as a nonlinear, discrete approach
to state transition systems.

Less structure means, as always, that fewer theorems are true and fewer
useful tools are available. On the other hand, less structure means that more
situations ﬁt the axioms, so that the theorems that are true and the tools
that do exist work for more applications.

3.2.5 Example A particularly important example of a monoid action oc-
curs in the study of ﬁnite state machines. Let A be a ﬁnite set, the alphabet
of the machine, whose elements may be thought of as characters or tokens,
and let S be another ﬁnite set whose elements are to be thought of as states.
We assume there is a distinguished state s0 ∈ S called the start state, and
a function φ : A × S −→ S deﬁning a transition to a state for each token in
A and each state in S. Such a system M = (A, S, s0, φ) is a ﬁnite state
machine. Note that there is no question of imposing axioms such as A–1
and A–2 because A is not a monoid.

Any string w in A∗ induces a sequence of transitions in the machine M
starting at the state s0 and ending in some state s. Precisely, we deﬁne a
function φ∗ : A∗ × S −→ S by:

FA–1 φ∗((), s) = s for s ∈ S.
FA–2 φ∗((a)w, s) = φ(a, φ∗(w, s)) for any s ∈ S, w ∈ A∗ and a ∈ A.

Recall that the free monoid F (A) is the set A∗ with concatenation as
multiplication. The function φ∗ as just deﬁned is thus an action of F (A)
on S. The identity of A∗ is the empty word () and by FA–1, φ∗((), a) = a
for all a ∈ A, so A–1 follows. As for A–2, if we assume that

φ∗(wv, m) = φ∗(w, φ∗(v, m))

for words w of length k, then

φ∗((a)wv, m) = φ(a, φ∗(wv, m))
= φ(a, φ∗(w, φ∗(v, m))) = φ∗((a)w, φ∗(v, m))

The ﬁrst and third equality are from the deﬁnition of φ, while the second is
from the inductive hypothesis.

76

Functors

Finite state machines in the literature often have added structure. The state
space may have a subset F of acceptor states (or ﬁnal states). The subset
L of A∗ of strings which drive the machine from the start state to an acceptor
state is then the set of strings, or language, which is recognized by the machine
M . This is the machine as recognizer. A compiler typically uses a ﬁnite state
machine to recognize identiﬁers in the input ﬁle.

Another approach is to assume that the machine outputs a string of symbols
(not necessarily in the same alphabet) for each state it enters or each transition
it undergoes. This is the machine as transducer.

An elementary introduction to ﬁnite state machines may be found in [Lewis and
Papadimitriou, 1981]. Two more advanced texts which use algebraic methods
to study ﬁnite state machines (primarily as recognizers) are those by Eilen-
berg [1976] and Lallement [1979]. The latter book has many other applications
of semigroup theory as well.

3.2.6 Set-valued functors as actions
idea of an action by introducing typing. What would the result be?

Suppose we wanted to extend the

To begin with, we would suppose that in addition to the state space S,
there was a type set T and a function type : S −→ T that assigned to each
element s ∈ S an element type(s) ∈ T .

In describing the elements of M , one must say, for an m ∈ M and s ∈ S,
what is type(ms). Moreover, it seems that one might well want to restrict
the types of the inputs on which a given m acts. In fact, although it might
not be strictly necessary in every case, it seems clear that we can, without
loss of generality, suppose that each m ∈ M acts on only one kind of input
and produces only one kind of output. For if m acted on two types of output,
we could replace m by two elements, one for each type. Thus we can imagine
that there are two functions we will call input and output from M to T for
which input(m) is the type of element that m acts on and output(m) is the
type of m(s) for an element s of type input(m).

In the untyped case, we had that M was a monoid, but here it is clearly
appropriate to suppose that m1 ∗ m2 is deﬁned only when output(m2) =
input(m1). It is reasonable to suppose that for each type t, there is an op-
eration 1t ∈ M whose input and output types are t and such that for any
m ∈ M of input type t, we have m ∗ 1t = m and for any m ∈ M of output
type t, we have 1t ∗ m = m.

As for the action, we will evidently wish to suppose that when s ∈ S has
type t and m, m(cid:48) ∈ M have input types t, t(cid:48), respectively, and output types
t(cid:48), t(cid:48)(cid:48), respectively, then m(cid:48)(m(s)) = (m(cid:48) ∗ m)(s) and 1t(s) = s.

Now it will not have escaped the reader at this point that M and T
together constitute a category C whose objects are the elements of T and
arrows are the elements of M . The input and output functions are just the
source and target arrows and the 1t are the identities.

3.2 Actions

77

M and S make up exactly the data of a set-valued functor on C . Deﬁne
a functor F : C −→ Set by letting F (t) = {s ∈ S | type(s) = t}. If m is an
arrow of C , that is an element of M , let its input and output types be t and
t(cid:48), respectively. Then for F to be a functor, we require a function F (m) : F (t)
−→ F (t(cid:48)). Naturally, we deﬁne F (m)(s) = ms, which indeed has type t(cid:48). The
facts that F preserves composition and identities are an easy consequence
of the properties listed above.

This construction can be reversed. Let C be a small category and suppose
we have a functor F : C −→ Set for which F (C) and F (D) are disjoint
whenever C and D are distinct objects of C (this disjointness requirement
is necessary to have a category, but can be forced by a simple modiﬁcation
of F – see Exercise 6 of Section 4.5). Then we can let T be the set of objects
of C , M the set of arrows and S =
t∈T F (t). The rest of the deﬁnitions are
evident and we leave them to the reader.

(cid:83)

Thus if C is a small category, a functor F : C −→ Set is an action which

generalizes the concept of monoid acting on a set.

3.2.7 Example For any given object C of a category C , the hom functor
Hom(C, −) (see 3.1.20) is a particular example of a set-valued functor. When
the category C is a monoid, it is the action by left multiplication familiar in
semigroup theory. A theorem generalizing the Cayley theorem for groups is
true, too (see 4.5.2).

3.2.8 Variable sets
It may be useful to think of a set-valued functor F :
C −→ Set as an action, not on a typed set, but on a single variable set.
The objects of C form a parameter space for the variation of the set being
acted upon. Another way of saying this is that each object of C is a point of
view, that the set being acted upon looks diﬀerent from diﬀerent points of
view, and the arrows of C are changes in point of view (as well as inducing
transitions). See [Barr, McLarty and Wells, 1985].

3.2.9 Machines with typed actions The concept generalizing ﬁnite state
machines is based on the perception that words in a typed alphabet are paths
in a graph whose nodes are the types.

Formally, a typed ﬁnite state machine consists of a graph G and a
graph homomorphism φ from G to the category of ﬁnite sets. Thus for each
node n of G there is a set φ(n), and for each arrow f : m −→ n of G there is
a function φ(f ) : φ(m) −→ φ(n).

What corresponds to the action of the free monoid on the states in the
case of ordinary ﬁnite state machines is the action of the free category F (G )
generated by G . The words in the free monoid are now paths in the free
category. The action φ generates an action φ∗ : F (G ) −→ Set according to
this recursive deﬁnition, which is a precise generalization of Section 3.2.5.

78

Functors

FA(cid:48)–1 φ∗(()C)(x) = x for x ∈ F (C), where ()C denotes the empty path from

C to C.
FA(cid:48)–2 For x ∈ dom(f1),

φ∗(fn, fn−1, . . . , f1)(x) = φ∗(fn, . . . , f2)[φ(f1)(x)]

This in other notation is a special case of the functor F (φ) deﬁned

in 3.1.13.

3.2.10 Remark If you wanted to model nondeterminism, φ(f ) for an arrow
f : m −→ n could not be a set function because the result of applying φ(f ) to
φ(m) might take a state of φ(m) to several states, or no state, of φ(n). One
way to solve this would be to take the meaning of the action in Rel instead
of in Set. Speciﬁcally, φ(m) would consist of the ordered pairs (x, y) with
the property that the action of m could take x to y. If the machine stalls on
x, then there would be no pair in φ(m) beginning with x.

This example is the tip of an iceberg. Probably the commonest type of
research article that applies category theory to computing science is one
that proposes some speciﬁc category other than Set to be the semantics of
a certain kind of program or programming language.

3.2.11 Example We can illustrate typed states by modeling an applica-
tion program with modes. Let’s suppose we have a program that can do two
diﬀerent things. It has three modes, one in which you choose what to do and
the other two which perform the two tasks. For simplicity, we suppose that
the two tasks are to recognize two languages L1 and L2 using ﬁnite state
machines m1 and m2 respectively. This conﬁguration can be exhibited as a
graph G :

(cid:82)

m1

x
(cid:190) 1
q

(cid:73)
y

(cid:45)

c

(cid:190)

(cid:82)
(cid:45)2
q

m2

x

(cid:73)
y

(3.2)

This assumes the two languages are subsets of {x, y}∗. The two arrows
labeled x are two diﬀerent arrows with the same label. The same remark
applies to y and q (which can be interpreted as ‘quit’).

To make an actual typed ﬁnite state machine using this schema, let us
suppose that L1 is the language of all those strings ending with x and L2 is
the language of all those strings that start with x. These are recognized by
the following machines, in which s is the start state, s accepts in M1 and
o accepts in M2. The states labeled b can be thought of as ‘bad’ and o as
‘OK’.

3.2 Actions

79

x

(cid:82)
(cid:45)

s

b

(cid:190) y
x

(cid:73)
y

(M1)

(cid:82)

b

x
(cid:190) y
(cid:73)
y

(cid:82)
o(cid:45)x

s

x

(cid:73)
y

(M2)

(3.3)

Let C be the free category generated by G . We deﬁne a functor F : C
−→ Set that implements the machine described in the previous paragraph.
To avoid confusion, we put subscripts 1 or 2 on the start states and the
states labeled b of the two machines to distinguish them. Then F is deﬁned
on objects by

(i) F (c) = {s, a, r}. s is ‘start’, a is ‘accept’ and r is ‘reject’.
(ii) F (m1) = {s1, b1}.
(iii) F (m2) = {s2, o, b2}.

The values of F on arrows are exhibited in this table. The occurrence of r
in the row marked b1 and the column marked q means that F (q)(b1) = r. A
blank means the function is not deﬁned at that symbol. This table is more
compact than it might be because it takes advantage of the fact that two
arrows each are labeled x, y and q.

1
s1
s1
s1

2
s2
s2
s2

q x

y

a s1
s1
r
r
o
a o
b2
r

b1
b1
b2
o
b2

s
a
r
s1
b1
s2
o
b2

You can check, for example, that feeding this machine the string 1yxxq
causes it to wind up in state a, and feeding it 1yyq2xyyq causes it to wind
up in state a after passing through state r at the ﬁrst q. One could attach
an output function to node c causing it to report acceptance or rejection.
Note that many strings (for example any string not starting with 1 or 2) are
not allowed as input because they violate the typing rules. One could add a
node e (for error) to G with appropriate transitions to account for this. F (e)
might then have several states corresponding to diﬀerent kinds of errors.

We have made some choices in saying that F (1) and F (2) can be applied
to a and r. For example, we could have reconﬁgured the graph G to split
the nodes c into two nodes, one for starting and one for reporting a result.

80

Functors

3.2.12 Exercise

1. Let S be a set. The full transformation monoid on S, denoted F T (S),
is the set of all functions from S to S with composition as the operation.
Show that the following is equivalent to the deﬁnition in 3.2.1 of monoid
action: an action by a monoid M on S is a monoid homomorphism from M
to F T (S).

3.3 Types of functors

Since Cat is a category, we already know about some types of functors.
Thus a functor F : C −→ D is an isomorphism if there is a functor G : D
−→ C which is inverse to F . This implies that F is bijective on objects and
arrows and conversely a functor which is bijective on objects and arrows is
an isomorphism.

We have already pointed out (Exercise 4 of Section 3.1) that a functor
is a monomorphism in Cat if and only if it is injective on both objects
and arrows. Epimorphisms in Cat need not be surjective, since the example
in 2.9.3 is actually an epimorphism in Cat between the categories determined
by the monoids (Exercise 8).

3.3.1 Full and faithful We will now consider properties of functors which
are more intrinsic to Cat than the examples just given.
Any functor F : C −→ D induces a set mapping

HomC (A, B) −→ HomD (F (A), F (B))

for each pair of objects A and B of C . This mapping takes an arrow f : A
−→ B to F (f ) : F (A) −→ F (B).

3.3.2 Deﬁnition A functor F : C −→ D is faithful if the induced map-
ping is injective on every hom set.

Thus if f : A −→ B and g : A −→ B are diﬀerent arrows, then F (f ) (cid:54)=
F (g). However, it is allowed that f : A −→ B and g : C −→ D may be diﬀerent
arrows, with F (A) = F (C), F (B) = F (D) and F (f ) = F (g), provided that
either A (cid:54)= C or B (cid:54)= D.

3.3.3 Example Underlying functors are typically faithful. Two diﬀerent
monoid homomorphisms between the same two monoids must be diﬀerent
as set functions.

On the other hand, consider the set {0, 1, 2}. It has two diﬀerent monoid
structures via addition and multiplication (mod 3) (and many other monoid
structures, too), but the two corresponding identity homomorphisms are the

3.3 Types of functors

81

same as set functions (have the same underlying function). Thus underlying
functors need not be injective.

3.3.4 Deﬁnition A functor F : C −→ D is full if the induced mapping is
surjective for every hom set.

A full functor need not be surjective on either objects or arrows. A full
subcategory (2.6.3) is exactly one whose embedding is a full and faithful
functor.

That the underlying functor from the category of semigroups to the cat-
egory of sets is not full says exactly that not every set function between
semigroups is a semigroup homomorphism. Note that this functor is sur-
jective on objects, since every set can be made into a semigroup by letting
xy = x for every pair x and y of elements.

3.3.5 Example The functor F : C −→ D which takes A and B to C and
X and Y to Z (and so is forced on arrows) in the picture below (which
omits identity arrows) is not full. That is because Hom(A, B) is empty, but
Hom(F (A), F (B)) = Hom(C, C) has an arrow in it – the identity arrow. This
functor is faithful even though not injective, since two arrows between the
same two objects do not get identiﬁed.

A

B

(cid:54)

(cid:54)

(cid:63)
X

(cid:63)
Y

C

C

(cid:54)

(cid:63)
Z

D

(3.4)

3.3.6 Preservation of properties A functor F : C −→ D preserves a
property P of arrows if whenever f has property P , so does F (f ).

3.3.7 Examples The fact that a monomorphism in the category of mon-
oids must be injective can be worded as saying that the underlying functor
preserves monomorphisms (since an injective function in Set is a mono-
morphism). The statement that an epimorphism in Mon need not be sur-
jective is the same as saying that the underlying functor does not preserve
epimorphisms.

As another example, consider the functor F : 2 −→ Set (2 is shown
in (2.1), page 18) deﬁned by C (cid:55)→ {1, 2}, D (cid:55)→ {3, 4} and the arrow from
C to D going to the constant function 1 (cid:55)→ 3, 2 (cid:55)→ 3 from F (C) to F (D).
The arrow from C to D is monic and epic (vacuously) but its value in Set

82

Functors

takes 1 and 2 both to 3, so is not injective and hence not a monomorphism.
It is also not an epimorphism. Thus F preserves neither monomorphisms nor
epimorphisms.

The story is diﬀerent for isomorphisms. (Note that the arrow from C to

D in 2 is not an isomorphism!)

3.3.8 Proposition Every functor preserves isomorphisms.

Proof. This is because the concept of isomorphism is deﬁned in terms of
equations involving composition and identity. If f : A −→ B is an isomorph-
ism with inverse g, then F (g) is the inverse of F (f ). One of the two calcu-
lations necessary to prove this is that F (g) ◦ F (f ) = F (g ◦ f ) = F (idA) =
idF (A); the other calculation is analogous.

3.3.9 Deﬁnition A functor F : C −→ D reﬂects a property P of arrows
if whenever F (f ) has property P then so does f (for any arrow that F takes
to F (f )).

It follows from 2.5.5 and the deﬁnition of isomorphism (2.7.4) that a
bijective semigroup homomorphism must be an isomorphism. That is the
same as saying that the underlying functor from Sem to Set reﬂects iso-
morphisms. The same remark applies to Mon. The underlying functor from
the category of posets and monotone maps does not reﬂect isomorphisms
(see 2.7.11).

A full and faithful functor reﬂects isomorphisms, but in fact it does a bit

more than that, as described by the following proposition.

3.3.10 Proposition Let F : C −→ D be full and faithful, and suppose A
and B are objects of C and u : F (A) −→ F (B) is an isomorphism in D.
Then there is a unique isomorphism f : A −→ B for which F (f ) = u.

Proof. By fullness, there are arrows f : A −→ B and g : B −→ A for which
F (f ) = u and F (g) = u−1. Then

F (g ◦ f ) = F (g) ◦ F (f ) = u−1 ◦ u = idF (A) = F (idA)
But F is faithful, so g ◦ f = idA. A similar argument shows that f ◦ g = idB,
so that g is the inverse of f .

3.3.11 Corollary A full and faithful functor reﬂects isomorphisms.

3.3.12 Corollary Let F : C −→ D be a full and faithful functor. If F (A) =
F (B) for objects A and B of C , then A and B are isomorphic.

Proof. Apply Proposition 3.3.10 to the identity arrow from F (A) to F (A) =
F (B).

3.3 Types of functors

83

3.3.13 You can also talk about a functor preserving or reﬂecting a property
of objects. For example, since a terminal object in Mon is a one-element
monoid and a one-element set is a terminal object, the underlying functor
from Mon to Set preserves terminal objects. It also reﬂects terminal objects.
It does not preserve initial objects, but it does reﬂect initial objects although
vacuously: the empty set is the only initial object in Set and the underlying
set of a monoid cannot be empty since it must have an identity element. We
leave the details to you.

3.3.14 Exercises

1. What does it mean for a functor to be faithful if

a. it is between the categories determined by monoids?
b. it is between the categories determined by posets?

2. Same question as 1 for ‘full’.

3. Is the forgetful functor from Mon to Sem full?

4. Is the free monoid functor faithful? Full?

5. Show that the powerset functor is faithful but not full.

6. Show that Rel is isomorphic to its own dual.

7. Show that a groupoid (see Exercise 11) is isomorphic to its own dual.

8. Show that the example in 2.9.3 is an epimorphism in Cat when the mon-
oids involved are regarded as categories; hence epimorphisms in Cat need
not be surjective.

9. Prove that every functor preserves split monos and split epis.

10. a. Does the underlying functor from Sem to Set preserve or reﬂect
initial objects? What about terminal objects?

b. Same questions for the underlying functor from Cat to Grf (3.1.10).

11. Show that for any category C and object A of C , the hom functor
Hom(A, −) (see 3.1.20) preserves terminal objects.

12. Let C be a category and f : B −→ A an arrow of C . Show that the slice
category (C /A)/f is isomorphic to the slice category C /B. (‘A slice of a
slice of C is a slice of C .’) Hint: The functor from (C /A)/f to C /B takes an
object w : (g : C −→ B) −→ f to g : C −→ B, and its inverse takes an object
u : C −→ B to u : f ◦ u −→ f .

84

Functors

3.4 Equivalences

In this section we deﬁne what it means for two categories to be equivalent.
The correct concept turns out to be weaker than requiring that they be
isomorphic – that is, that there is a functor from one to the other which has
an inverse in Cat. In order to understand the issues involved, we ﬁrst take
a close look at the construction of the category corresponding to a monoid
in Section 2.3.12. It turns out to be a functor.

3.4.1 Monoids and one-object categories For each monoid M we con-
structed a small category C(M ) in 2.3.12. We make the choice mentioned
there that the one object of C(M ) is M . Note that although an element of
C(M ) is now an arrow from M to M , it is not a set function.

For each monoid homomorphism h : M −→ N , construct a functor C(h) :

C(M ) −→ C(N ) as follows:

CF–1 On objects, C(h)(M ) = N .
CF–2 C(h) must be exactly the same as h on arrows (elements of M ).

It is straightforward to see that C(h) is a functor and that this con-
struction makes C a functor from Mon to the full subcategory of Cat of
categories with exactly one object. We will denote this full subcategory as
Ooc.

There is also a functor U : Ooc −→ Mon going the other way.

UO–1 For a category C with one object, U (C ) is the monoid whose elements
are the arrows of C and whose binary operation is the composition
of C .

UO–2 If F : C −→ D is a functor between one-object categories, U (F ) = F1,

that is, the functor F on arrows.

The functors U and C are not inverse to each other, and it is worthwhile

to see in detail why.

The construction of C is in part arbitrary. We needed to regard each
monoid as a category with one object. The choice of the elements of M to
be the arrows of the category is obvious, but what should be the one object?
We chose M itself, but we could have chosen some other thing, such as the
set {e}, where e is the identity of M . The only real requirement is that it
not be an element of M (such as its identity) in order to avoid set-theoretic
problems caused by the category being an element of itself. The consequence
is that we have given a functor C : Mon −→ Ooc in a way which required
arbitrary choices.

The arbitrary choice of one object for C(M ) means that if we begin with
a one-object category C , construct M = U (C ), and then construct C(M ),

3.4 Equivalences

85

the result will not be the same as C unless it happens that the one object
of C is M . Thus C ◦ U (cid:54)= idOoc, so that U is not the inverse of C. (In this
case U ◦ C is indeed idMon.)

C is not surjective on objects, since not every small category with one
object is in the image of C; in fact a category D is C(M ) for some monoid
M only if the single object of D is actually a monoid and the arrows of
D are actually the arrows of that monoid. This is entirely contrary to the
spirit of category theory: we are talking about speciﬁc elements rather than
specifying behavior. Indeed, in terms of specifying behavior, the category of
monoids and the category of small categories with one object ought to be
essentially the same thing.

The fact that C is not an isomorphism of categories is a signal that
isomorphism is the wrong idea for capturing the concept that two categories
are essentially the same. However, every small category with one object is
isomorphic to one of those constructed as C(M ) for some monoid M . This
is the starting point for the deﬁnition of equivalence.

3.4.2 Deﬁnition A functor F : C −→ D is an equivalence of categories
if there are:

E–1 A functor G : D −→ C .
E–2 A family uC : C −→ G(F (C)) of isomorphisms of C indexed by the
objects of C with the property that for every arrow f : C −→ C(cid:48) of C ,
G(F (f )) = uC(cid:48) ◦ f ◦ u−1
C .

E–3 A family vD : D −→ F (G(D)) of isomorphisms of D indexed by the
objects of D, with the property that for every arrow g : D −→ D(cid:48) of D,
F (G(g)) = vD(cid:48) ◦ g ◦ v−1
D .

If F is an equivalence of categories, the functor G of E–1 is called a
pseudo-inverse of F . That the functor C of 3.4.1 is an equivalence (with
pseudo-inverse U ) is left as an exercise. The families u and v are natural
isomorphisms, and the arrows uD and vD are components of the natural
isomorphism. These concepts are deﬁned in general in 4.2.18.

The idea behind the deﬁnition is that not only is every object of D iso-
morphic to an object in the image of F , but the isomorphisms are compatible
with the arrows of D; and similarly for C . (See Exercise 6 of Section 4.2.)

3.4.3 Example Let C be the category with two objects A and B, their
identities, and two other arrows i : A −→ B and j : B −→ A that are inverse
isomorphisms between the objects:

A

(cid:190)

(cid:45)i
j

B

(3.5)

86

Functors

Let D = 1 be the category with one object E and its identity arrow. Then
C and D are equivalent. The unique functor from C to D has two pseudo-
inverses, each taking the unique object of D to one of the two isomorphic
objects of C .

We give the details for one of these. Let F : C −→ D be the functor that
takes A and B to E and G : D −→ C the functor that takes E to A. The
family required by E–2 consists of uA = idA and uB = j. That required by
E–3 consists of idE. We have for example

G(F (i)) = G(idE) = idA = j ◦ i ◦ idA = uB ◦ i ◦ uA

−1

The other equations required by E–2 and E–3 are similar or easier.

3.4.4 Theorem Let F : C −→ D be an equivalence of categories and G :
D −→ C a pseudo-inverse to F . Then F and G are full and faithful.

Proof. Actually, something more is true: if F and G are functors for which
E–2 is true, then F is faithful. For suppose f, f (cid:48) : C −→ C(cid:48) in C and F (f ) =
F (f (cid:48)) in D. Then G(F (f )) = G(F (f (cid:48))) in C , so that

f = u−1

C(cid:48) ◦ G(F (f )) ◦ uC = u−1

C(cid:48) ◦ G(F (f (cid:48))) ◦ uC = f (cid:48)

Thus F is faithful. A symmetric argument shows that if E–3 is true then G
is faithful.

Now suppose F : C −→ D is an equivalence of categories and G : D −→ C
is a pseudo-inverse to F . We now know that F and G are faithful. To show
that F is full, suppose that g : F (C) −→ F (C(cid:48)) in D. We must ﬁnd f : C
−→ C(cid:48) in C for which F (f ) = g. Let f = u−1
C(cid:48) ◦ G(g) ◦ uC. Then a calculation
using E–2 shows that G(F (f )) = G(g). Since G is faithful, F (f ) = g.

Proposition 3.3.10 implies that an equivalence of categories does not take

nonisomorphic objects to isomorphic ones.

An alternative deﬁnition of equivalence sometimes given in the literature
uses the concept of representative functor. A functor F : C −→ D is repre-
sentative if every object of D is isomorphic to an object in the image of
F . (Thus a subcategory is representative in the sense of Deﬁnition 2.7.14 if
the inclusion functor is representative.) Then a functor F : C −→ D is an
equivalence if it is full, faithful, and representative. This deﬁnition can be
proved equivalent to ours. The proof requires the axiom of choice.

3.4.5 Inequivalence For any property P of a category that can be de-
ﬁned in terms of composition and identities, if C and D are equivalent cate-
gories, then either they both have property P or neither of them does. This
is an imprecise statement; in particular, a property preserved by equiva-
lence can require that two arrows be the same but it cannot require that

3.4 Equivalences

87

two objects be the same. A formal language that expresses the properties
preserved by equivalence is given by Freyd and Scedrov [1990], sections 1.39–
1.3(10). See also [Bergman and Berman, 1998].

This observation provides a way to show that two categories are not
equivalent. For example, Set and Mon are not equivalent because there is
no arrow in Set from the terminal object to the initial object, but in Mon the
initial and terminal objects are isomorphic. Similarly Set and the category
of posets and monotone functions are not equivalent because there are only
two nonisomorphic sets that have only one automorphism (the empty set
and a singleton set), but there are many nonisomorphic posets that have
only one automorphism, for example any two totally ordered ﬁnite posets of
diﬀerent cardinality.

3.4.6 Example The category Fin, of ﬁnite sets and functions between
them, is equivalent to the opposite of the category of ﬁnite Boolean algebras
and homomorphisms between them. We sketch the construction here, omit-
ting the many necessary veriﬁcations. (Boolean algebras are deﬁned in 5.7.5.)
A homomorphism h : B −→ B(cid:48) is a monotone function which preserves meets,
joins, (cid:62), ⊥ and complements (these requirements are redundant).

Let FBool denote the category of ﬁnite Boolean algebras and homo-
morphisms. Let F : Finop −→ FBool take a ﬁnite set to its powerset, which
is a Boolean algebra with inclusion for the ordering. If f : S −→ T is a func-
tion, F (f ) : PT −→ PS takes a subset of T to its inverse image under f ;
this function F (f ) is a homomorphism of Boolean algebras.

To construct the pseudo-inverse, we need a deﬁnition. An atom in a
ﬁnite Boolean algebra B is an element a for which there are no elements
b ∈ B such that ⊥ < b < a. It is a fact that any element b ∈ B is the join of
the set of atoms beneath it (this may be false in inﬁnite Boolean algebras).
It is also true that if h : B −→ B(cid:48) is a homomorphism of Boolean algebras
and A is the set of atoms of B, then the join of all the elements h(a) for
a ∈ A is (cid:62) in B(cid:48), and for any two atoms a1, a2 of B, h(a1) ∧ h(a2) = ⊥. It
follows from this that if b(cid:48) is an atom of B(cid:48), then there is a unique atom a
of B for which b(cid:48) ≤ h(a).

Now deﬁne a functor G : FBoolop −→ Fin as follows. Let B be a ﬁnite
Boolean algebra. Then G(B) is the set of atoms of B. If h : B −→ B(cid:48) is a
homomorphism, then G(h) : G(B(cid:48)) −→ G(B) takes an atom a(cid:48) of B(cid:48) to the
unique atom a of B for which a(cid:48) ≤ h(a). This makes G a functor.

3.4.7 Proposition The functor F is an equivalence with pseudo-inverse
G.

The component of the required natural isomorphism from a ﬁnite set S
to G(F (S)) takes an element x ∈ S to the singleton {x}. The component of

88

Functors

the natural isomorphism from a ﬁnite Boolean algebra B to F (G(B)) (the
latter is the set of all subsets of all the atoms of B) takes an element b ∈ B
to the set of atoms under b. We omit the details.

3.4.8 Exercises

1. Prove that a functor which is an isomorphism in Cat is an equivalence.
2.† Let Pfn denote the category of sets and partial functions deﬁned in 2.1.13.
Let Pts denote the category whose objects are sets with a distinguished ele-
ment (called pointed sets) and whose arrows are functions which preserve
the distinguished element. In other words, if S is a set with distinguished
element s and T is a set with distinguished element t, then an arrow of Pts
is a function f : S −→ T for which f (s) = t. Show that Pfn and Pts are
equivalent categories. (Hint: The functor from Pfn adds a new element to
each set and completes each partial function to a total function by assigning
the new element to each element where it was formerly undeﬁned. The func-
tor in the other direction takes a pointed set to the set without the point
and if a function has the distinguished point as a value for some input, it
becomes undeﬁned at that input.)

3. Show that the category of preordered sets and increasing maps is equiva-
lent to the full category of those small categories with the property that
Hom(A, B) never has more than one element.
4.† (For the reader conversant with vector spaces and linear mappings.) Let
L denote the category of ﬁnite dimensional vector spaces and linear maps.
Let M be the category whose objects are the natural numbers, and for which
an arrow M : m −→ n is an n × m matrix. When n = 0 or m = 0 or both,
there is just one arrow called 0. Composition is matrix multiplication. Any
composite involving 0 gives the 0 arrow. Show that L and M are equivalent
categories.

5. a. Prove that the functor C : Mon −→ Ooc constructed in 3.4.1 is an
equivalence of categories.

b. Prove directly, without using Theorem 3.4.4, that it is full and faithful.

3.5 Quotient categories

A quotient of a category by a congruence relation on the arrows is very
similar to the concept of the quotient of a monoid by a congruence relation.
We will describe the construction from scratch; you need not know about
congruence relations to understand it. The construction we describe is not
the most general possible: it merges arrows, but not objects.

3.5 Quotient categories

89

The constructions of this section are used in 4.1.13 and in the chapters

on sketches.

3.5.1 Deﬁnition An equivalence relation ∼ on the arrows of a category
C is a congruence relation if:

CR–1 Whenever f ∼ g, then f and g have the same domain and the same

codomain.

CR–2 In this setting,

h

−−→ B

A

f
−−→−−→
g

k

−−→ D

C

if f ∼ g, then f ◦ h ∼ g ◦ h and k ◦ f ∼ k ◦ g.

We denote the congruence class containing the arrow f by [f ].

3.5.2 Deﬁnition Let ∼ be a congruence relation on the arrows of C . De-
ﬁne the quotient category C /∼ as follows.

QC–1 The objects of C /∼ are the objects of C .
QC–2 The arrows of C /∼ are the congruence classes of arrows of C .
QC–3 If f : A −→ B in C , then [f ] : A −→ B in C /∼.
QC–4 If f : A −→ B and g : B −→ C in C , then [g] ◦ [f ] = [g ◦ f ] : A −→ C

in C /∼.

It follows from Exercise 1 that QC–4 is well deﬁned and that the result

is indeed a category.

3.5.3 Deﬁnition Let C /∼ be the quotient of a category C by a congru-
ence relation ∼. Deﬁne Q : C −→ C /∼ by QA = A for an object A and
Qf = [f ] for an arrow f of C .

It is immediate from QC–4 that Q is a functor.

3.5.4 Proposition Let ∼ be a congruence relation on a category C . Let
F : C −→ D be any functor with the property that if f ∼ g then F (f ) = F (g).
Then there is a unique functor F0 : C /∼ −→ D for which F0 ◦ Q = F .

The proposition says that every way of passing from C to some other
category which merges congruent arrows factors through Q uniquely. This
can be perceived in another way: C /∼ is the category constructed from C
by making the fewest identiﬁcations consistent with forcing two congruent
arrows in C to be the same arrow.

90

Functors

3.5.5 Factorization of functors Every functor factors through a faith-
ful one in the following precise sense. Let F : C −→ D be a functor. The
relation ∼ induced by F on arrows of C is deﬁned by requiring that
f ∼ g if and only if f and g have the same domain and codomain and
F (f ) = F (g).

3.5.6 Proposition The relation ∼ induced by F is a congruence relation
on C , and the functor F0 : C /∼ −→ D induced by Proposition 3.5.4 is faith-
ful.

The proof is contained in Exercise 4 below.
A faithful set-valued functor (see 3.3.2) is one for which two diﬀerent
arrows act diﬀerently on at least one state. In the special case of monoid
actions this is precisely the deﬁnition of ‘faithful’ used in the literature (not
a coincidence), and the preceding proposition is a well-known fact about
monoid actions.

3.5.7 The intersection of any set of congruence relations on a category is
also a congruence relation (Exercise 2). This means that if α is any relation
on C with the property that if f αg then f and g have the same domain
and the same codomain, then there is a unique smallest congruence relation
generated by α.

Thus in particular given two arrows f : A −→ B and g : A −→ B in a
category C , there is a quotient category by the congruence relation generated
by requiring that f = g. This is called imposing the relation f = g. Two
arrows in C are merged in the quotient category if requiring that f = g
forces them to be merged.

3.5.8 The category of a programming language We described in 2.2.6
the category C(L) corresponding to a simple functional programming lan-
guage L deﬁned there. We can now say precisely what C(L) is.

The deﬁnition of L in 2.2.5 gives the primitive types and operations of
the language. The types are the nodes and the operations are the arrows of
a graph. This graph generates a free category F (L), and the equations im-
posed in 2.2.5(ii) and (iv) (each of which says that two arrows of C(L) must
be equal) generate a congruence relation as just described. The resulting
quotient category is precisely C(L).

When one adds constructors such as record types to the language, the
quotient construction is no longer enough. Then it must be done using
sketches. The construction just given is in fact a special case of a model
of a sketch (see Section 4.6).

3.5 Quotient categories

91

3.5.9 Functorial semantics Functors provide a way to give a meaning
to the constructs of the language L just mentioned. This is done by giving
a functor from C(L) to some category suitable for programming language
semantics, such as those discussed in 2.4.3.

We illustrate this idea here using a functor to Set as the semantics for the
language described in 2.2.5. Set is for many reasons unsuitable for program-
ming language semantics, but it is the natural category for expressing our
intuitive understanding of what programming language constructs mean.

Following the discussion in 2.2.5, we deﬁne a semantics functor Σ : C(L)
−→ Set. To do this, ﬁrst we deﬁne a function F on the primitive types and
operations of the language.

(i) F (NAT) is the set of natural numbers. The constant 0 is the number 0

and F (succ) is the function which adds 1.

(ii) F (BOOLEAN) is the set {true, false}. The constants true and false
are the elements of the same name, and F (¬) is the function which
switches true and false.

(iii) F (CHAR) is the set of 128 ASCII symbols, and each symbol is a constant.
(iv) F (ord) takes a character to its ASCII value, and F (chr) takes a num-

ber n to the character with ASCII code n modulo 128.

Let F (L) be the free category generated by the graph of types and opera-
tions, as in 2.6.16. By Proposition 3.1.15, there is a functor (cid:98)F : F (L) −→ Set
which has the eﬀect of F on the primitive types and operations.

This functor (cid:98)F has the property required by Proposition 3.5.4 that if ∼
is the congruence relation on F (L) generated by the equations of 2.2.5(ii)
and (iv), then f ∼ g implies that (cid:98)F (f ) = (cid:98)F (g) (Exercise 5). This means that
there is a functor Σ : C(L) −→ Set (called F0 in Proposition 3.5.4) with the
property that if x is any primitive type or operation, then Σ(x) = F (x).

The fact that Σ is a functor means that it preserves the meaning of
programs; for example the program (path of arrows) chr ◦ succ ◦ ord ought
to produce the next character in order, and in fact

Σ(chr ◦ succ ◦ ord)

does just that, as you can check. Thus it is reasonable to refer to Σ as a
possible semantics of the language L.

We will return to this example in Section 4.3.12. The construction of
C(L) and Σ are instances of the construction of the theory of a sketch in
Section 7.5.

92

Functors

3.5.10 Exercises

1. Show that an equivalence relation ∼ satisfying CR–1 is a congruence
relation if and only if, for all arrows f1, f2, g1, g2 as in this diagram,

A

f1−−→−−→
f2

B

g1−−→−−→
g2

C

if f1 ∼ f2 and g1 ∼ g2, then g1 ◦ f1 ∼ g2 ◦ f2.

2. Show that the intersection of congruence relations is a congruence rela-
tion.

3. Show that the quotient functor in 3.5.3 is full. (Warning: This exercise
would be incorrect if we allowed the more general deﬁnition of quotient,
which allows merging objects as well as arrows.)

4. Let F : C −→ D be a functor.

a. Show that the relation ∼ induced by F (deﬁned in 3.5.5) is a congruence

relation.

b. Show that the induced functor F0 : C /∼ −→ D is faithful.
c. Conclude from this and the preceding exercise that every functor F : C

−→ D factors as a full functor followed by a faithful functor.
5. Let (cid:98)F and ∼ be deﬁned as in 3.5.9. Prove that f ∼ g implies that (cid:98)F (f ) =
(cid:98)F (g).

6. Let M be a monoid. A congruence on M is an equivalence relation ∼
with the property that it is a congruence relation for the category C(M )
determined by M .

a. Show that an equivalence relation ∼ on M is a congruence relation if
and only if for all elements m, n, n(cid:48) of M , if n ∼ n(cid:48) then mn ∼ mn(cid:48) and
nm ∼ n(cid:48)m.

b. Let K be the subset {(m, n) | m ∼ n} of the monoid M × M . Show
that K is a submonoid of M × M if and only if ∼ is a congruence relation.
(M × M is the monoid whose elements are all ordered pairs of elements of
M with multiplication (m, n)(m(cid:48), n(cid:48)) = (mm(cid:48), nn(cid:48)).)

4
Diagrams, naturality
and sketches

Commutative diagrams are the categorist’s way of expressing equations. Nat-
ural transformations are maps between functors; one way to think of them is
as a deformation of one construction (construed as a functor) into another.
A sketch is a graph with imposed commutativity and other conditions; it is
a way of expressing structure. Models of the structure are given by functors,
and homomorphisms between them by natural transformations.

All this will become clearer as the chapter is read. It turns out that the
concepts just mentioned are all very closely related to each other. Indeed,
there is a sense in which diagrams, functors and models of sketches are all
diﬀerent aspects of the same idea: they are all types of graph homomorphisms
in which some or all of the graphs are categories.

The ﬁrst three sections introduce diagrams, commutative diagrams and
natural transformations, three basic ideas in category theory. These concepts
are used heavily in the rest of the book. Section 4.4 gives the Godement rules.
These form the basis of the algebra of functors and natural transformations,
which is studied in more abstract form in Section 4.8.

Section 4.5 introduces the concepts of representable functor, the Yoneda
embedding and universal elements. Working through the details of this pre-
sentation is an excellent way of learning to work with natural transforma-
tions.

We also recommend studying the introduction to linear sketches and lin-
ear sketches with constants in Sections 4.6 and 4.7 as an excellent way to
familiarize yourself with both commutative diagrams and natural transfor-
mations. However, these two sections may be skipped unless you are going
to read Chapters 7, 8, 10 or 11.

Section 4.8 introduces 2-categories, a notion of category that allows map-
pings between arrows (called 2-cells) that has been found useful to model
program reﬁnement, among other things. This section is not used in the rest
of the book.

93

94

Diagrams, naturality and sketches

4.1 Diagrams

We begin with diagrams in a graph and discuss commutativity later.

4.1.1 Deﬁnition Let I and G be graphs. A diagram in G of shape I
is a homomorphism D : I −→ G of graphs. I is called the shape graph of
the diagram D.

We have thus given a new name to a concept which was already deﬁned
(not uncommon in mathematics). A diagram is a graph homomorphism from
a diﬀerent point of view.

4.1.2 Example At ﬁrst glance, Deﬁnition 4.1.1 may seem to have little
to do with what are informally called diagrams, for example

A

h(cid:64)

(cid:64)(cid:82)

B(cid:45)f
g(cid:161)

(cid:161)(cid:170)

C

(4.1)

The connection is this: a diagram in the sense of Deﬁnition 4.1.1 is pic-
tured on the page with a drawing of nodes and arrows as for example in
Diagram (4.1), which could be the picture of a diagram D with shape graph

i
w(cid:64)

(cid:64)(cid:82)

j(cid:45)u
v(cid:161)

(cid:161)(cid:170)

k

(4.2)

deﬁned by D(i) = A, D(j) = B, D(k) = C, D(u) = f , D(v) = g and D(w) =
h.

4.1.3 Example Here is an example illustrating some subtleties involving
the concept of diagram. Let G be a graph with objects A, B and C (and
maybe others) and arrows f : A −→ B, g : B −→ C and h : B −→ B. Consider
these two diagrams, where here we use the word ‘diagram’ informally:

A

B(cid:45)f

C(cid:45)g

(a)

A

h

B(cid:45)f (cid:82)
(b)

(4.3)

These are clearly of diﬀerent shapes (again using the word ‘shape’ infor-
mally). But the diagram

A

B(cid:45)f

B(cid:45)h

(4.4)

4.1 Diagrams

95

is the same shape as (4.3)(a) even though as a graph it is the same as (4.3)(b).
To capture the diﬀerence thus illustrated between a graph and a diagram,

we introduce two shape graphs

1

2(cid:45)u

3(cid:45)v

I

1

w

2(cid:45)u (cid:82)
J

(4.5)

(where, as will be customary, we use numbers for the nodes of shape graphs).
Now diagram (4.3)(a) is seen to be the diagram D : I −→ G with D(1) = A,
D(2) = B, D(3) = C, D(u) = f and D(v) = g; whereas diagram (4.3)(b) is
E : J −→ G with E(1) = A, E(2) = B, E(u) = f and E(w) = h. Moreover,
Diagram (4.4) is just like D (has the same shape), except that v goes to h
and 3 goes to B.

4.1.4 Our deﬁnition in 4.1.1 of a diagram as a graph homomorphism, with
the domain graph being the shape, captures both the following ideas:

(i) A diagram can have repeated labels on its nodes and (although the

examples did not show it) on its arrows, and

(ii) Two diagrams can have the same labels on their nodes and arrows
but be of diﬀerent shapes: Diagrams (4.3)(b) and (4.4) are diﬀerent
diagrams because they have diﬀerent shapes.

4.1.5 Commutative diagrams When the target graph of a diagram is
the underlying graph of a category some new possibilities arise, in partic-
ular the concept of commutative diagram, which is the categorist’s way of
expressing equations.

In this situation, we will not distinguish in notation between the category
and its underlying graph: if I is a graph and C is a category we will refer
to a diagram D : I −→ C .

We say that D is commutative (or commutes) provided for any nodes

i and j of I and any two paths

k1

(cid:45)s2

k2

· · ·(cid:45)

kn−2(cid:45)

kn−1(cid:45)sn−1

s1 (cid:161)(cid:161)(cid:181)
i
t1 (cid:64)(cid:64)(cid:82)

l1

t2

(cid:45)

l2

· · ·(cid:45)

lm−2(cid:45)

tm−1

sn(cid:64)(cid:64)(cid:82)
j
tm(cid:161)(cid:161)(cid:181)

lm−1(cid:45)

(4.6)

96

Diagrams, naturality and sketches

from i to j in I , the two paths

(cid:45)Ds2

Dk1

Dk2

· · ·(cid:45)

(cid:45)

Dkn−2

(cid:45)Dsn−1

Dkn−1

Ds1 (cid:161)(cid:161)(cid:181)
Di
Dt1 (cid:64)(cid:64)(cid:82)

Dl1

(cid:45)

Dt2

Dl2

· · ·(cid:45)

(cid:45)

Dlm−2

(cid:45)
Dtm−1

Dsn(cid:64)(cid:64)(cid:82)
Dj
Dtm(cid:161)(cid:161)(cid:181)

Dlm−1

(4.7)

compose to the same arrow in C . This means that

Dsn ◦ Dsn−1 ◦ . . . ◦ Ds1 = Dtm ◦ Dtm−1 ◦ . . . ◦ Dt1

4.1.6 Much ado about nothing There is one subtlety to the deﬁnition
of commutative diagram: what happens if one of the numbers m or n in
Diagram (4.7) should happen to be 0? If, say, m = 0, then we interpret the
above equation to be meaningful only if the nodes i and j are the same (you
go nowhere on an empty path) and the meaning in this case is that

Dsn ◦ Dsn−1 ◦ . . . ◦ Ds1 = idDi

(you do nothing on an empty path). In particular, a diagram D based on
the graph

e

(cid:82)

i

commutes if and only if D(e) is the identity arrow from D(i) to D(i).

Note, and note well, that both shape graphs

e

(cid:82)

i

(a)

i

j(cid:45)d

(b)

have models that one might think to represent by the diagram

f

(cid:82)

A

but the diagram based on (a) commutes if and only if f = idA, while the
diagram based on (b) commutes automatically (no two nodes have more
than one path between them so the commutativity condition is vacuous).

We will always picture diagrams so that distinct nodes of the shape graph
are represented by distinct (but possibly identically labeled) nodes in the

4.1 Diagrams

97

picture. Thus a diagram based on (b) in which d goes to f and i and j both
go to A will be pictured as

f

−−→ A

A

In consequence, one can always deduce the shape graph of a diagram from
the way it is pictured, except of course for the actual names of the nodes
and arrows of the shape graph.

4.1.7 Examples of commutative diagrams – and others The proto-
typical commutative diagram is the triangle

A

h(cid:64)

(cid:64)(cid:82)

B(cid:45)f
g(cid:161)

(cid:161)(cid:170)

C

(4.8)

that commutes if and only if h is the composite g ◦ f . The reason this is
prototypical is that any commutative diagram – unless it involves an empty
path – can be replaced by a set of commutative triangles. This fact is easy to
show and not particularly enlightening, so we are content to give an example.
The diagram

A

B(cid:45)h

f

(cid:63)
C

g

(cid:63)
D(cid:45)

k

commutes if and only if the two diagrams

A

(cid:64)

(cid:64)

f

(cid:63)
C

g ◦ h
(cid:64)
(cid:64)(cid:82)
D(cid:45)

k

A

B(cid:45)h

(cid:64)
k ◦ f

(cid:64)

(cid:64)

(cid:64)(cid:82)

g

(cid:63)
D

(4.9)

(4.10)

commute (in fact if and only if either one does).

4.1.8 Example An arrow f : A −→ B is an isomorphism with inverse g :
B −→ A if and only if

A

(cid:190)

(cid:45)f
g

B

(4.11)

98

Diagrams, naturality and sketches

commutes. The reason for this is that for this diagram to commute, the two
paths () and (g, f ) from A to A must compose to the same value in the
diagram, which means that g ◦ f = idA. A similar observation shows that
f ◦ g must be idB.

4.1.9 Graph homomorphisms by commutative diagrams The deﬁ-
nition of graph homomorphism in 1.4.1 can be expressed by a commutative
diagram. Let φ = (φ0, φ1) be a graph homomorphism from G to H . For
any arrow u : m −→ n in G , 1.4.1 requires that φ1(u) : φ0(m) −→ φ0(n) in
H . This says that φ0(source(u)) = source(φ1(u)), and a similar statement
about targets. In other words, these diagrams must commute:

G1

H1(cid:45)φ1

G1

H1(cid:45)φ1

source

source

target

target

(4.12)

(cid:63)
G0

(cid:63)
H0(cid:45)

φ0

(cid:63)
G0

(cid:63)
H0(cid:45)

φ0

In these two diagrams the two arrows labeled ‘source’ are of course diﬀerent
functions; one is the source function for G and the other for H . A similar
remark is true of ‘target’.

4.1.10 This point of view provides a pictorial proof that the composite of
two graph homomorphisms is a graph homomorphism (see 2.4.1). If φ : G
−→ H and ψ : H −→ K are graph homomorphisms, then to see that ψ ◦ φ
is a graph homomorphism requires checking that the outside rectangle below
commutes, and similarly with target in place of source:

G1

H1(cid:45)φ1

K1(cid:45)ψ1

source

(cid:63)
G0

φ0

source

(cid:63)
H0(cid:45)

source

(4.13)

(cid:63)
K0(cid:45)

ψ0

The outside rectangle commutes because the two squares commute. This can
be checked by tracing (mentally or with a ﬁnger or pointer) the paths from
G1 to K0 to verify that

source ◦ ψ1 ◦ φ1 = ψ0 ◦ source ◦ φ1

(4.14)

because the right square commutes, and that

ψ0 ◦ source ◦ φ1 = ψ0 ◦ φ0 ◦ source

(4.15)

4.1 Diagrams

99

because the left square commutes. The veriﬁcation process just described
is called ‘chasing the diagram’. Of course, one can verify the required fact
by writing the equations (4.14) and (4.15) down, but those equations hide
the source and target information given in Diagram (4.13) and thus provide
a possibility of writing an impossible composite down. For many people,
Diagram (4.13) is much easier to remember than equations (4.14) and (4.15).
However, diagrams are more than informal aids; they are formally-deﬁned
mathematical objects just like automata and categories.

The proof in 2.6.10 that the composition of arrows in a slice gives another

arrow in the category can be represented by a similar diagram:

C

(cid:64)
f

C(cid:48)(cid:45)h
f (cid:48)
(cid:63)
A

(cid:64)(cid:82)

(cid:64)

C(cid:48)(cid:48)(cid:45)h(cid:48)
f (cid:48)(cid:48)(cid:161)

(cid:161)

(cid:161)(cid:170)

These examples are instances of pasting commutative diagrams together to
get bigger ones. (See 4.8.16.)

4.1.11 Associativity by commutative diagrams The fact that the mul-
tiplication in a monoid or semigroup is associative can be expressed as the
assertion that a certain diagram in Set commutes.

Let S be a semigroup. Deﬁne the following functions, using the cartesian

product notation for functions of 1.2.9:

(i) mult : S × S −→ S satisﬁes mult(x, y) = xy.
(ii) S × mult : S × S × S −→ S × S satisﬁes

(S × mult)(x, y, z) = (x, yz)

(iii) mult ×S : S × S × S −→ S × S satisﬁes

(mult ×S)(x, y, z) = (xy, z)

That the following diagram commutes is exactly the associative law.

S × S × S

S × mult

(cid:45)

S × S

mult ×S

(cid:63)
S × S

mult
(cid:63)

S(cid:45)

mult

(4.16)

100

Diagrams, naturality and sketches

4.1.12 Normally, associativity is expressed by the equation x(yz) = (xy)z
for all x, y, z in the semigroup. The commutative diagram expresses this same
fact without the use of variables. Of course, we did use variables in deﬁning
the functions involved, but we remedy that deﬁciency in Chapter 5 when we
give a categorical deﬁnition of products.

Another advantage of using diagrams to express equations is that dia-
grams show the source and target of the functions involved. This is not par-
ticularly compelling here but in other situations the two-dimensional picture
of the compositions involved makes it much easier to follow the discussion.

4.1.13 In 3.5.7, we described how to force two arrows in a category C to
be the same by going to a quotient category. More generally, you can make
any set D of diagrams in C commute, by imposing all the relations of the
form

Dsn ◦ Dsn−1 ◦ . . . ◦ Ds1 ∼ Dtm ◦ Dtm−1 ◦ . . . ◦ Dt1

where

(cid:45)Ds2

Dk1

Dk2

· · ·(cid:45)

(cid:45)

Dkn−2

(cid:45)Dsn−1

Dkn−1

Ds1 (cid:161)(cid:161)(cid:181)
Di
Dt1 (cid:64)(cid:64)(cid:82)

Dl1

(cid:45)

Dt2

Dl2

· · ·(cid:45)

(cid:45)

Dlm−2

(cid:45)
Dtm−1

Dsn(cid:64)(cid:64)(cid:82)
Dj
Dtm(cid:161)(cid:161)(cid:181)

Dlm−1

(4.17)

are two paths in any diagram D ∈ D. As before, if one of these paths is the
empty path the other must be an identity arrow in order for the diagram to
commute.

4.1.14 Diagrams as functors In much of the categorical literature, a
diagram in a category C is a functor D : E −→ C where E is a category. Be-
cause of Proposition 3.1.15, a graph homomorphism into a category extends
uniquely to a functor based on the free category generated by the graph, so
that diagrams in our sense generate diagrams in the functorial sense. On the
other hand, any functor is a graph homomorphism on the underlying graph
of its domain (although not conversely!), so that every diagram in the sense
of functor is a diagram in the sense of graph homomorphism.

4.2 Natural transformations

101

4.1.15 Exercises

1. Draw a commutative diagram expressing the fact that an arrow f : A
−→ B factors through an arrow g : C −→ B. (See 2.8.9.)

2. Draw a commutative diagram to express the fact that addition of real
numbers is commutative.

3. Draw commutative diagrams expressing the equations occurring in the
deﬁnition of the sample functional programming language in 2.2.5.

4. Express the deﬁnition of functor using commutative diagrams.

4.2 Natural transformations

4.2.1 Unary operations
In Section 4.1 we saw that diagrams in a cat-
egory are graph homomorphisms to the category from a diﬀerent point of
view. Now we introduce a third way to look at graph homomorphisms to a
category, namely as models. To give an example, we need a deﬁnition.

4.2.2 Deﬁnition A unary operation on a set S is a function u : S −→ S.

This deﬁnition is by analogy with the concept of binary operation on a
set. A set with a unary operation is a (very simple) algebraic structure, which
we call a u-structure. If the set is S and the operation is f : S −→ S, we
say that (S, f ) is a u-structure, meaning (S, f ) denotes a u-structure whose
underlying set is S, and whose unary operation is f . This uses positional
notation in much the same way as procedures in many computer languages:
the ﬁrst entry in the expression ‘(S, f )’ is the name of the underlying set of
the u-structure and the second entry is the name of its operation.

4.2.3 A homomorphism of u-structures should be a function which pre-
serves the structure. There is really only one deﬁnition that is reasonable for
this idea: if (S, u) and (T, v) are u-structures, f : S −→ T is a homomorph-
ism of u-structures if f (u(s)) = v(f (s)) for all s ∈ S. Thus this diagram
must commute:

T(cid:45)f

S

u

(cid:63)
S

f

v

(cid:63)

T(cid:45)

(4.18)

It is not diﬃcult to show that the composite of two homomorphisms of u-
structures is another one, and that the identity map is a homomorphism, so
that u-structures and homomorphisms form a category.

102

Diagrams, naturality and sketches

4.2.4 Models of graphs We now use the concept of u-structure to mo-
tivate the third way of looking at graph homomorphisms to a category.

4.2.5 Let U be the graph with one node u0 and one arrow e:

e

(cid:82)

u0

Let us deﬁne a graph homomorphism D : U −→ Set as follows: D(u0) = R
and D(e) = x (cid:55)→ x2. Now (R, x (cid:55)→ x2) is a u-structure, and the notation we
have introduced in 4.2.1 tells us that we have chosen R to be its underlying
set and x (cid:55)→ x2 to be its unary operation. Except for the arbitrary names ‘u0’
and ‘e’, the graph homomorphism D communicates the same information:
‘R is the particular set chosen to be the value of u0, and x (cid:55)→ x2 is the
particular function chosen to be the value of e.’

In this sense, a u-structure is essentially the same thing as a diagram
in Set of shape U : a u-structure ‘models’ the graph U . This suggests the
following deﬁnition.

4.2.6 Deﬁnition A model M of a graph G is a graph homomorphism
M : G −→ Set.

We will see how to deﬁne a monoid as a model involving a graph homo-
morphism (and other ingredients) in Chapter 7. We had to introduce u-
structures here to have an example for which we had the requisite techniques.
The technique we are missing is the concept of product in a category, which
allows the deﬁnition of operations of arity (see Deﬁnition 7.7.1) greater than
one.

Both category theory and mathematical logic have concepts of ‘model’. Both are
formalisms attempting to make precise the relationship between the (formal)
description of a mathematical structure and the structure itself. In logic, the
precise description (the syntax) is given by a logical theory; in category theory
by sketches or by categories regarded as theories. Good introductions to various
aspects of categorical logic and model theory are given by [Makkai and Reyes,
1977], [Lambek and Scott, 1986], [Makkai and Par´e, 1990] and [Ad´amek and
Rosiˇcky, 1994].

4.2.7 Example As another example, consider this graph (see 1.3.9):

a

source
−−−−−→
−−−−−→
target

n

(4.19)

A model M of this graph consists of sets G0 = M (n) and G1 = M (a) together
with functions source = M (source) : G1 −→ G0 and target = M (target) : G1

4.2 Natural transformations

103

−→ G0. To understand what this structure is, imagine a picture in which there
is a dot corresponding to each element of G0 and an arrow corresponding
to each element a ∈ G1 which goes from the dot corresponding to source(a)
to the one corresponding to target(a). It should be clear that the picture so
described is a graph and thus the graph (4.19) is a graph whose models are
graphs!

This deﬁnition makes the semantics of 1.3.9 into a mathematical con-

struction.

4.2.8 Models in arbitrary categories The concept of model can be
generalized to arbitrary categories: if C is any category, a model of G in C
is a graph homomorphism from G to C . For example, a model of the graph
for u-structures in the category of posets and monotone maps is a poset and
a monotone map from the poset to itself.

In this book, the bare word ‘model’ always means a model in Set.

4.2.9 Natural transformations between models of a graph In a cat-
egory, there is a natural notion of an arrow from one model of a graph to
another. This usually turns out to coincide with the standard deﬁnition of
homomorphism for that kind of structure.

4.2.10 Deﬁnition Let D, E : G −→ C be two models of the same graph
in a category. A natural transformation α : D −→ E is given by a family
of arrows αa of C indexed by the nodes of G such that:

NT–1 αa : Da −→ Ea for each node a of G .
NT–2 For any arrow s : a −→ b in G , the diagram
Ea(cid:45)αa

Da

Ds

(cid:63)
Db

Es
(cid:63)
Eb(cid:45)

αb

(4.20)

commutes.

The commutativity of the diagram in NT–2 is referred to as the natu-
rality condition on α. The arrow αa for an object a is the component of
the natural transformation α at a.

Note that you talk about a natural transformation from D to E only
if D and E have the same domain (here G ) as well as the same codomain
(here C ) and if, moreover, the codomain is a category. In this situation, it
is often convenient to write α : D −→ E : G −→ C .

104

Diagrams, naturality and sketches

4.2.11 Deﬁnition Let D, E and F be models of G in C , and α : D −→ E
and β : E −→ F natural transformations. The composite β ◦ α : D −→ F is
deﬁned componentwise: (β ◦ α)a = βa ◦ αa.

4.2.12 Proposition The composite of two natural transformations is also
a natural transformation.

Proof. The diagram that has to be shown commutative is the outer rectangle
of

Da

Ea(cid:45)αa

F a(cid:45)βa

Ds

(cid:63)
Db

Es
(cid:63)
Eb(cid:45)

αb

βb

F s
(cid:63)
F b(cid:45)

(4.21)

for each arrow s : a −→ b in G . The rectangle commutes because the two
squares do; the squares commute as a consequence of the naturality of α
and β.

It is interesting that categorists began using modes of reasoning like that in the
preceding proof because objects of categories generally lacked elements; now
one appreciates them for their own sake because they allow element-free (and
thus variable-free) arguments.

4.2.13 It is even easier to show that there is an identity natural transfor-
mation between any model D and itself, deﬁned by (idD)a = idDa. We then
have the following proposition, whose proof is straightforward.

4.2.14 Proposition The models of a given graph G in a given category C ,
and the natural transformations between them, form a category. We denote
this category by Mod(G , C ).

4.2.15 Example The natural transformations between models in Set of
the u-structure graph U deﬁned in 4.2.5 are exactly the homomorphisms of
u-structures deﬁned in 4.2.3. The graph described in 4.2.5 has one object u0
and one arrow e, so that a natural transformation from a model D to a model
E has only one component which is a function from D(u0) to E(u0). If we
set S = D(u0), u = D(e), T = E(u0), v = E(e), and we deﬁne αu0 = f , this
is the single component of a natural transformation from D to E. Condition
NT–2 in 4.2.10 coincides in this case with the diagram in 4.2.3: the naturality
condition is the same as the deﬁnition of homomorphism of u-structures. It
follows that the category of u-structures and homomorphisms is essentially
Mod(U , Set).

4.2.16 Example A homomorphism of graphs is a natural transformation
between models of the graph

4.2 Natural transformations

105

a

source
−−−−−→
−−−−−→
target

n

The two graphs in Diagram (4.12) are the two necessary instances (one for
the source and the other for the target) of Diagram (4.20). In a similar way,
Diagram (4.21), used to show that the composite of two natural transforma-
tions is a natural transformation, reduces in this case to the commutativity
of Diagram (4.13): speciﬁcally, the only possibilities (other than those in
which s is an identity arrow) for a and b in Diagram (4.21) are a = a and
b = n, giving two diagrams shaped like Diagram (4.21), one for s = source
(that is Diagram (4.13)) and the other for s = target.

4.2.17 Example A model of the graph

0

1(cid:45)u

(4.22)

in an arbitrary category C is essentially the same as an arrow in C (see 4.2.22
below). A natural transformation from the model represented by the arrow
f : A −→ B to the one represented by g : C −→ D is a pair of arrows h : A
−→ C and k : B −→ D making a commutative diagram:

A

C(cid:45)h

f

(cid:63)
B

g

(cid:63)
D(cid:45)

k

(4.23)

The component at 0 is h and the component at 1 is k. The category of models
in C is called the arrow category of C ; it is often denoted C −→.

4.2.18 Natural isomorphisms A natural transformation α : F −→ G :
G −→ D is called a natural isomorphism if there is a natural transfor-
mation β : G −→ F which is an inverse to α in the category Mod(G , D).
Natural isomorphisms are often called natural equivalences.

4.2.19 Example The arrow (h, k) : f −→ g in the arrow category of a
category C , as shown in (4.23), is a natural isomorphism if and only if h and
k are both isomorphisms in C . This is a special case of an important fact
about natural isomorphisms, which we now state.

106

Diagrams, naturality and sketches

4.2.20 Theorem Suppose F : G −→ D and G : G −→ D are models of G
in D and α : F −→ G is a natural transformation of models. Then α is a
natural isomorphism if and only if for each node a of G , αa : F (a) −→ G(a)
is an isomorphism of D.

Proof. Suppose α has an inverse β : G −→ F in Mod(G , D). Then for any
node a, by Deﬁnition 4.2.11, Deﬁnition 4.2.13, and the deﬁnition of inverse,

and

αa ◦ βa = (α ◦ β)a = idG a = idG(a)

βa ◦ αa = (β ◦ α)a = idF a = idF (a)

which means that the arrow βa is the inverse of the arrow αa, so that αa is
an isomorphism in D as required.

Conversely, suppose that for each node a of G , αa : F (a) −→ G(a) is an
isomorphism of D. The component of the inverse β at a node a is deﬁned
by letting βa = (αa)−1. This is the only possible deﬁnition, but it must be
shown to be natural. Let f : a −→ b be an arrow of the domain of F and G.
Then we have

F f ◦ (αa)−1 = (αb)−1 ◦ (αb) ◦ F f ◦ (αa)−1
= (αb)−1 ◦ Gf ◦ (αa) ◦ (αa)−1
= (αb)−1 ◦ Gf

which says that β is natural. The second equality uses the naturality of α.

4.2.21 Monic natural transformations Let α : F −→ G be a natural
transformation between models of G in D. Suppose each component of α is
a monomorphism in D. Then it is easy to prove that α is a monomorphism
in Mod(G , D).

However, in contrast to Theorem 4.2.20, the converse need not be true.
As an example (thanks to Andrew Richardson), let D be the subcategory of
Set consisting of

(a) Objects: {1}, {1, 2}, {1, 2, 3} and {1, 2, 4}.
(b) Arrows:

(i) The identity functions.
(ii) g : {1, 2} −→ {1}, h : {1, 2, 3} −→ {1} and k : {1, 2, 4} −→ {1} the

only possible functions.

(iii) f : {1, 2, 3} −→ {1, 2} and u : {1, 2, 4} −→ {1, 2} the constant func-

tions with value 1.

(iv) v : {1, 2, 4} −→ {1, 2} the constant function with value 2.

4.2 Natural transformations

107

(c) Composition of set functions as composition.

The category can be pictured like this:

{1, 2, 3}

{1}(cid:45)h

f

(cid:63)
{1, 2}

id{1}
(cid:63)
{1}(cid:45)
g

{1, 2, 4} (cid:45)u
(cid:45)
v

(4.24)

The square commutes, so (h, g) : f −→ id{1} is an arrow in D−→. Moreover,
(h, g) is monic in D−→ (because the only natural transformation with codo-
main f is (id{1,2,3}, id{1,2})) but its component g is not monic in D because
g ◦ u = g ◦ v.

4.2.22 ‘Essentially the same’
In 4.2.17, we said that a model in an ar-
bitrary category C of the graph (4.22) is ‘essentially the same’ as an arrow
in C . This is common terminology and usually refers implicitly to an equiva-
lence of categories. We spell it out in this case.

Let us say that for a category C , C (cid:48) is the category whose objects are
the arrows of C and for which an arrow from f to g is a pair (h, k) making
Diagram (4.23) commute.

A model M of the graph (4.22) in a category C speciﬁes the objects
M (0) and M (1) and the arrow M (u). M (u) has domain M (0) and codomain
M (1). But the domain and codomain of an arrow in a category are uniquely
determined by the arrow. So that the only necessary information is which
arrow M (u) is.

Now we can deﬁne a functor F : C −→ −→ C (cid:48). On objects it take M
to M (u). The remarks in the preceding paragraph show that this map on
objects is bijective. If M (u) = f and N (u) = g, an arrow from M to N in
C −→ and an arrow from f to g in C (cid:48) are the same thing – a pair (h, k)
making Diagram (4.23) commute. So we say F is the identity on arrows. It
is straightforward to see that F is actually an isomorphism of categories.
Exercise 4 below gives another example of this phenomenon.

In most texts, the arrow category C −→ is deﬁned the way we deﬁned C (cid:48).

When being very careful, one would say as above that a model in C of the
graph (4.22) is essentially the same as an arrow in C , and that a u-structure is
essentially the same as a model of U (as in 4.2.15). Frequently, one says more
bluntly that a model of (4.22) in C is an arrow in C and that a u-structure
is a model of U (and ‘is an N-set’ – see Exercise 2). This usage is perhaps
based on the conception that the description ‘model of (4.22) in C ’ and ‘arrow

108

Diagrams, naturality and sketches

in C ’ are two ways of describing the same mathematical object, which exists
independently of any particular description. Not all mathematicians share this
conception of mathematical objects.

4.2.23 Exercises

1. What is the model of (4.2.7) that is the graph (4.2.7)?

2. Let N denote the monoid of nonnegative integers with addition as oper-
ation. Give explicit isomorphisms between these categories:

(i) The category u-Struc of u-structures and homomorphisms, as deﬁned

in 4.2.3.

(ii) Mod(U , Set), deﬁned in 4.2.5 and 4.2.14.
(iii) N-Act, as deﬁned in 3.2.1.

3. Let C be a category with object B. Exhibit the slice category C /B as a
subcategory of the arrow category of C deﬁned in 4.2.17 (see 2.6.10). Is it
full?

4. Let G be the graph with two nodes and no arrows, and C any category.
Show that Mod(G , C ) is isomorphic to C × C .

5. Prove directly, without using Theorem 4.2.20, that in Diagram (4.23), the
arrow (h, k) is an isomorphism in the arrow category of C if and only if h
and k are both isomorphisms in C .

6. Let C and D be categories and F : C −→ D an equivalence. Show that
every arrow of D is isomorphic in the arrow category of D to an arrow in
the image of F . (In this sense, an equivalence of categories is ‘surjective up
to isomorphism’ on both objects and arrows. See 3.4.2.)
7. Let G be a graph and C a category and let C −→ be the arrow category
as in 4.2.17. Show that there is a one-one correspondence between models of
G in C −→ and triples (E, α, F ) where E and F are models of G in C and
α : E −→ F is a natural transformation between them. (More about this in
Exercise 8 of Section 4.3.)

8. Suppose D, E : G −→ C are two models of a graph in a category and
α : D −→ E is a natural isomorphism. Suppose we let, for a a node of G ,
βa = (αa)−1. Show that the collection of βa forms a natural transformation
(a natural isomorphism in fact) from E to D.

4.3 Natural transformations between functors

109

4.3 Natural transformations

between functors

A functor is among other things a graph homomorphism, so a natural trans-
formation between two functors is a natural transformation of the corre-
sponding graph homomorphisms. The following proposition is an immediate
consequence of 4.2.12.

4.3.1 Proposition If C and D are categories, the functors from C to D
form a category with natural transformations as arrows.

We denote this category by Func(C , D). Other common notations for
it are D C and [C , D]. Tennent [1986] provides an exposition of the use of
functor categories for programming language semantics.

Of course, the graph homomorphisms from C to D, which do not neces-
sarily preserve the composition of arrows in C , also form a category Mod(C , D)
(see 4.2.14), of which Func(C , D) is a full subcategory.

A natural transformation from one functor to another is a special case of
a natural transformation from one graph homomorphism to another, so the
ideas we have presented concerning natural transformations between graph
homomorphisms apply to natural transformations between functors as well.
In particular, Theorems 4.2.12 and 4.2.20 are true of natural transformations
of functors.

If C is not a small category (see 2.1.5), then Func(C , D ) may not be locally
small (see 2.1.7). This is a rather esoteric question that will not concern us in
this book since we will have no occasion to form functor categories of that sort.

We motivated the concept of natural transformation by considering models of
graphs, and most of the discussion in the rest of this section concerns that point
of view. Historically, the concept ﬁrst arose for functors and not from the point
of view of models.

4.3.2 Examples We have already described some examples of natural trans-
formations, as summed up in the following propositions.

In 3.1.14, we deﬁned the graph homomorphism ηG : G −→ U (F (G ))
which includes a graph G into U (F (G )), the underlying graph of the free
category F (G ).

4.3.3 Proposition The family of arrows ηG form a natural transforma-
tion from the identity functor on Grf to U ◦ F , where U is the underlying
graph functor from Cat to Grf .

The proof is left as an exercise.

In 3.4.2, we deﬁned the concept of equivalence of categories.

110

Diagrams, naturality and sketches

4.3.4 Proposition A functor F : C −→ D is an equivalence of categories
with pseudo-inverse G : D −→ C if and only if G ◦ F is naturally isomorphic
to idC and F ◦ G is naturally isomorphic to idD .

Proof. Conditions E–2 and E–3 of 3.4.2 can be recast as the statement that
G(F (f )) ◦ uC = uC(cid:48) ◦ f and that F (G(g)) ◦ vD = vD(cid:48) ◦ g, in other words
that the following diagrams commute:

(cid:45)uC

C

G(F (C))

(cid:45)vD

D

F (G(D))

f

G(F (f ))

g

F (G(g))

(cid:63)
C(cid:48)

(cid:45)
uC(cid:48)

(cid:63)
G(F (C(cid:48)))

(cid:63)
D(cid:48)

(cid:45)
vD(cid:48)

(cid:63)
F (G(D(cid:48)))

In this form, they are the statements that u is a natural transformation from
idC to G ◦ F and that v is a natural transformation from idD −→ F ◦ G. Since
each component of u and each component of v is an isomorphism, u and v
are natural equivalences.

4.3.5 Example Let α : M × S −→ S and β : M × T −→ T be two actions
by a monoid M (see 3.2.1). Let φ : S −→ T be an equivariant map. If F and
G are the functors corresponding to α and β, as deﬁned in 3.2.3, then φ is the
(only) component of a natural transformation from F to G. Conversely, the
only component of any natural transformation from F to G is an equivariant
map between the corresponding actions.

4.3.6 Example Let U : Mon −→ Set be the underlying functor from the
category of monoids. Deﬁne U × U : Mon −→ Set as follows:

(i) For a monoid M , (U × U )(M ) = U (M ) × U (M ).
(ii) For a monoid homomorphism h : M −→ N ,

(U × U )(h)(m, n) = (h(m), h(n))

Then monoid multiplication is a natural transformation from U × U to U .
Formally: Let µ : U × U −→ U be the family of maps whose value at a monoid
M is the function µM : U (M ) × U (M ) −→ U (M ) deﬁned by µM (m, m(cid:48)) =
mm(cid:48), the product of m and m(cid:48) in M . Then µ is a natural transformation.
(The function µM is not in general a monoid homomorphism, unless M is
commutative.)

It is instructive to see why µ is a natural transformation. Let h : M −→ N
be a monoid homomorphism. We must show that the following diagram

commutes:

4.3 Natural transformations between functors

111

(U × U )(M )

(cid:45)µM

U (M )

(U × U )(h)

(cid:63)
(U × U )(N )

h
(cid:63)
U (N )

(cid:45)

µN

(4.25)

The top route takes an element (m, m(cid:48)) ∈ (U × U )(M ) to h(mm(cid:48)). The lower
route takes it to h(m)h(m(cid:48)). The commutativity of the diagram then follows
from the fact that h is a homomorphism.

4.3.7 Example The bijection of Exercise 4 of Section 1.2 can be seen to
be a natural isomorphism, this time between contravariant functors.

Let B be a ﬁxed set. We deﬁne a functor R : Set op −→ Set such that
for a set A, R(A) = Rel(A, B) as deﬁned in the exercise. For a set function
F : A(cid:48) −→ A and relation α ∈ Rel(A, B), deﬁne R(F )(α) to be the relation
α(cid:48) ∈ Rel(A(cid:48), B) deﬁned by a(cid:48)α(cid:48)b if and only if F (a(cid:48))αb. It is easy to see that
this makes R : Set op −→ Set a functor. (Note that R(A) = Rel(A, B), but
R is not HomRel(−, B).)

For each A, let φA : Rel(A, B) −→ Hom(A, PB) be the bijection of the
exercise. If we check that the functions φA are the components of a natural
transformation from R to Hom(A, PB), the transformation will automati-
cally be a natural isomorphism by Theorem 4.2.20. To show that it is natural,
let α ∈ Rel(A, B) and a(cid:48) ∈ A(cid:48). Then

Hom(F, PB)

(cid:161)

(cid:162)
φA(α)(a(cid:48))

= φA(α)

(cid:161)

(cid:162)
F (a(cid:48))

= {b | F (a(cid:48))αb}

= {b | a(cid:48)α(cid:48)b} = φA(cid:48)

(cid:161)

(cid:162)
R(F )(a(cid:48))

as required.

This natural isomorphism can be taken to be the deﬁning property of a

topos (Section 15.2.2).

4.3.8 Natural transformations involving lists Many of the operations
on lists available in functional programming languages can be seen as natu-
ral transformations involving the Kleene closure or list functor (3.1.12). For
example, one can apply the Kleene closure twice to get the list of lists functor
that takes a set A to A∗∗. An element of A∗∗ is a list of lists. For example, if
A = {a, b}, one of the elements of A∗∗ is w = ((a, b), (b, b, a), (), (a)). If f : A
−→ B is a function, f ∗∗ takes w to ((f (a), f (b)), (f (b), f (b), f (a)), (), (f (a))).
The operation of ﬂattening a list simply concatenates the lists in the
list; for example, ﬂatten(w) = (a, b, b, b, a, a). Of course, ﬂatten is a distinct

112

Diagrams, naturality and sketches

function for each set A; if we write ﬂattenA : A∗∗ −→ A∗ for each set A, then
ﬂatten is a natural transformation from ∗∗ to ∗, as you can see by checking
that this diagram commutes for each function f : A −→ B:

A∗∗

ﬂattenA

A∗(cid:45)

f ∗∗

(cid:63)
B∗∗

f ∗
(cid:63)
B∗(cid:45)

ﬂattenB

(4.26)

Another operation in functional programming languages consists of applying
a binary operation to a list. This is called reduce, apply or fold. We shall
consider only the case when the binary operation is associative. (When it
is not associative, some choice is made about how to associate the list.)
This gives a natural transformation from F ◦ U to idMon, where F : Set
−→ Mon is the free monoid functor and U : Mon −→ Set is the underlying
set functor. For example, if M is a monoid with elements k, m and n, then
reduce(k, k, n, m) = k2nm, the product of the list using the operation of M .
In this case, naturality means that for any monoid homomorphism h : M
−→ N , h ◦ reduceM = reduceN ◦ F (U (h)), which is easily checked.

Note that although both reduce and ﬂatten take lists as arguments,
reduceM is a monoid homomorphism with domain F (U (M )) (whose ele-
ments are lists), whereas ﬂattenA is a set function with domain A∗∗. This is
reﬂected by the fact that, when implemented in a programming language,
reduce takes an operation as well as a list as argument, but ﬂatten takes
only a list.

These and other list operations can often be generalized to sets of expres-
sions instead of sets of lists. In particular, ﬂatten in this more general sense
is one of the fundamental constituents of triples (Section 14.3), namely µ.

More about these ideas may be found in [Bird, 1986] and [Spivey, 1989].

4.3.9 Natural transformations of graphs We now consider some nat-
ural transformations involving the category Grf of graphs and homomorph-
isms of graphs.

4.3.10 Example
In 3.1.9, we deﬁned the functor N : Grf −→ Set. It takes
a graph G to its set G0 of nodes and a homomorphism φ to φ0. Now pick a
graph with one node ∗ and no arrows and call it E . Let V = HomGrf (E , −).
A graph homomorphism from the graph E to an arbitrary graph G is evi-
dently determined by the image of E and that can be any node of G . In other
words, nodes of G are ‘essentially the same thing’ as graph homomorphisms
from E to G , that is, as the elements of the set V (G ).

4.3 Natural transformations between functors

113

We can deﬁne a natural transformation α : V −→ N by deﬁning

αG (f ) = f0(∗)

where G is a graph and f : E −→ G is a graph homomorphism (arrow of
Grf ). There must be a naturality diagram (4.20) for each arrow of the source
category, which in this case is Grf . Thus to see that α is natural, we require
that for each graph homomorphism g : G1 −→ G2, the diagram

V G1

(cid:45)V g

V G2

αG1

(cid:63)
N G1

αG2
(cid:63)
N G2

(cid:45)

N g

commutes. Now N g is g0 (the node map of g) by deﬁnition, and the value of
V (which is a hom functor) at a homomorphism g composes g with a graph
homomorphism from the graph E . Then we have, for a homomorphism f : E
−→ G1 (i.e., an element of the upper left corner of the diagram),

(αG2 ◦ V g)(f ) = αG2(g ◦ f ) = (g ◦ f )0(∗)

while

(N g ◦ αG1)(f ) = N g(f0(∗)) = g0(f0(∗))

and these are equal from the deﬁnition of composition of graph homomorph-
isms.

The natural transformation α is in fact a natural isomorphism (Ex-
ercise 9). This shows that N is naturally isomorphic to a hom functor.
Such functors are called ‘representable’, and are considered in greater de-
tail in 4.5.1.

4.3.11 Connected components A node a can be connected to the
node b of a graph G if it is possible to get from a to b following a sequence
of arrows of G in either direction. In order to state this more precisely, let
us say that an arrow a ‘has’ a node n if n is the domain or the codomain
(or both) of a. Then a is connected to b means that there is a sequence
(c0, c1, . . . , cn) of arrows of G with the property that a is a node (either the
source or the target) of c0, b is a node of cn, and for i = 1, . . . , n, ci−1 and
ci have a node in common. We call such a sequence an undirected path
between a and b.

It is a good exercise to see that ‘being connected to’ is an equivalence re-
lation. (For reﬂexivity: a node is connected to itself by the empty sequence.)

114

Diagrams, naturality and sketches

An equivalence class of nodes with respect to this relation is called a con-
nected component of the graph G , and the set of connected components
is called W G .

Connected components can be deﬁned for categories in the same way as

for graphs. In that case, each connected component is a full subcategory.

If f : G −→ H is a graph homomorphism and if two nodes a and b are in
the same component of G , then f (a) and f (b) are in the same component
of H ; this is because f takes an undirected path between a and b to an
undirected path between f (a) and f (b). Thus the arrow f induces a function
W f : W G −→ W H , namely the one which takes the component of a to the
component of f (a); and this makes W a functor from Grf to Set.

For a graph G , let βG : N G −→ W G be the set function which takes a
node of G to the component of G that contains that node. (The component
is the value of βG at the node, not the codomain.) Then β : N −→ W is a
natural transformation. It is instructive to check the commutativity of the
requisite diagram.

4.3.12 Example In 3.5.9, we described a functor Σ which provided a
meaning in Set for each program in the programming language L of 2.2.5.
A person more oriented to machine language might have preferred to give
the meaning of all the data in terms of numbers, in particular the integers
between 0 and 2K for some ﬁxed number K ≥ 7 (the constraint is to accom-
modate the ASCII codes).

Thus one could deﬁne a functor Σ(cid:48) for which

(i) Σ(cid:48)(NAT) is the set of integers between 0 and 2K − 1. Then the constant
0 would be the number 0, but Σ(cid:48)(succ) would have to calculate the
successor modulo 2K.

(ii) Σ(cid:48)(BOOLEAN) is the set {0, 1}, with true = 1 and false = 0.
(iii) For each character c, Σ(cid:48)(c) is the ASCII code for c. Then we would
have to take Σ(cid:48)(CHAR) to be the set A = {n ∈ N | 0 ≤ n ≤ 127}.

For each of the three types T in our language, we have a way of rewriting
each datum in Σ(T ) to become the corresponding datum in Σ(cid:48)(T ). This
rewriting becomes a function βT : Σ(T ) −→ Σ(cid:48)(T ):

(i) β(NAT)(n) is n modulo 2K.
(ii) β(BOOLEAN)(true) = 1 and β(BOOLEAN)(false) = 0.
(iii) β(CHAR)(c) is the ASCII code of c for each character c.

In order to preserve the intended meaning, Σ(cid:48)(succ) would have to be the
successor function modulo 2K, Σ(cid:48)(ord) would have to be the inclusion of A
into Σ(cid:48)(NAT) and Σ(cid:48)(chr) would have to be the function from Σ(cid:48)(NAT) to A
which takes the remainder modulo 128.

4.3 Natural transformations between functors

115

Preserving the meaning of ord (an informal idea) means formally that
this diagram must commute, as it does with the deﬁnitions given of Σ(ord)
and Σ(cid:48)(ord):

Σ(CHAR)

β(CHAR)

(cid:45)

Σ(cid:48)(CHAR)

Σ(ord)

(cid:63)

Σ(NAT)

Σ(cid:48)(ord)
(cid:63)
Σ(cid:48)(NAT)

(cid:45)

β(NAT)

Similar remarks apply to the preservation of the other operations. This is a
special case of a general principle that, given two functors G and G(cid:48) which
are semantics in some sense, a natural transformation β : G −→ G(cid:48) can be
said to preserve the meaning of the operations.

The natural transformation β was constructed for the given data types.
The only constructor in L, namely composition, does not destroy the natural
transformation property: if the given β gives the naturality property for
primitive operations, it does so for all their composites, as well. This is an
instance of the following proposition.

4.3.13 Proposition Let F, G : C −→ D be functors. Let S be a (possibly
empty) set of arrows of C with the property that every arrow of C is a
composite of arrows of S and let βC : F (C) −→ G(C) be an arrow of D for
each object C of C . Suppose for every arrow f : A −→ B of S this diagram
commutes:

F (A)

(cid:45)F (f )

F (B)

βA

(cid:63)
G(A)

βB

(cid:63)
G(B)

(cid:45)

G(f )

(4.27)

Then β is a natural transformation.

Proof. if f : A −→ B and g : B −→ C are arrows of S, then the outer rectangle
below commutes because the two squares do:

F (A)

(cid:45)F (f )

F (B)

(cid:45)F (g)

F (C)

βA

(cid:63)
G(A)

βB

(cid:63)
G(B)

βC

(cid:63)
G(C)

(cid:45)

G(g)

(cid:45)

G(f )

116

Diagrams, naturality and sketches

The naturality diagram for the case f = id (that is, the empty composite)
is automatic. The proof follows from these facts by induction.

4.3.14 Exercises

1. Prove Proposition 4.3.3.

2. Show that the family βG of arrows taking a node to its component deﬁned
in 4.3.11 is indeed a natural transformation.

3. Let C be a category. A subfunctor of a functor F : C −→ Set is a functor
G : C −→ Set with the property that for each object C of C , G(C) ⊆ F (C)
and such that for each arrow f : C −→ C(cid:48) and each element x ∈ GC, we have
that Gf (x) = F f (x). Show that the inclusion function iC : G(C) −→ F (C)
is a natural transformation.

4. Show that the map which takes an arrow of a graph to its source is a
natural transformation from A to N . (See 3.1.9.) Do the same for targets.
(Actually, every operation in any multisorted algebraic structure gives a nat-
ural transformation. Example 4.3.6 was another example of this. See [Linton,
1969b], [Linton, 1969a].)
5.† Show that if C is a discrete category with set of objects C0 (hence essen-
tially a set), then Func(C , Set) is equivalent to the slice category Set/C0.
(See 2.6.10.)

6. For each set S, let {}S : S −→ PS be the function which takes an element
x of S to the singleton subset {x}.

a. Show that {} is a natural transformation from the identity functor on

Set to the direct image powerset functor P. (See 3.1.16.)

b. Show that {} is not a natural transformation from the identity functor

on Set to the universal image powerset functor. (See 3.1.19.)

c. Explain why it does not even make sense to ask whether it is a natural

transformation to the inverse image powerset functor.

7. Verify the claims in 4.3.5.

8. Show that the results of Exercise 7 of Section 4.2 are still true if we replace
the graph G by a category D.

9. Show that the natural transformation of 4.3.10 is a natural isomorphism.

10. a. Show that for any integer k, the set of paths of length k of a graph
is the object part of a functor Pk : Grf −→ Set. (See 2.1.2.)

b. Show that P0 is naturally isomorphic to the node functor N deﬁned

in 3.1.9.

c. Show that P1 is naturally isomorphic to the arrow functor A of 3.1.9.

4.4 Godement calculus

117

4.4 The Godement calculus of
natural transformations

We collect here, mostly without proof, some of the basic combinatorial prop-
erties of functors and natural transformations. These rules were ﬁrst codi-
ﬁed by Godement [Godement, 1958]. The notation given in Deﬁnitions 4.4.2
and 4.4.3 is used throughout the book, but the remainder of this section is
used only in Section 4.8. Verifying (some of) the Godement properties is an
excellent way to familiarize yourself with natural transformations.

4.4.1 Let F : A −→ B and G : B −→ C be functors. There is a composite
functor G ◦ F : A −→ C deﬁned in the usual way by G ◦ F (A) = G(F (A)).
Similarly, let H, K and L be functors from A −→ B and α : H −→ K and
β : K −→ L be natural transformations. Recall that this means that for each
object A of A , αA : HA −→ KA and βA : KA −→ LA. Then as in 4.2.11, we
deﬁne β ◦ α : H −→ L by

(β ◦ α)A = βA ◦ αA

Things get more interesting when we mix functors and natural transfor-
mations. For example, suppose we have three categories A , B and C , four
functors, two of them, F, G : A −→ B and the other two H, K : B −→ C ,
and two natural transformations α : F −→ G and β : H −→ K. We picture
this situation as follows:

A

F
⇓ α

G

(cid:82)
(cid:181)

B

H
⇓ β

K

(cid:82)
(cid:181)

C

(4.28)

4.4.2 Deﬁnition The natural transformation βF : H ◦ F −→ K ◦ F is de-
ﬁned by the formula (βF )A = β(F A) for an object A of A .

The notation β(F A) means the component of the natural transformation
β at the object F A. This is indeed an arrow from H(F (A)) −→ K(F (A)) as
required. To show that βF is natural requires showing that for an arrow
f : A −→ A(cid:48) of A , the diagram

H(F (A))

(cid:45)βF A

K(F (A))

H(F (f ))

K(F (f ))

(4.29)

(cid:63)
H(F (A(cid:48)))

(cid:63)
K(F (A(cid:48)))

(cid:45)

βF A(cid:48)

118

Diagrams, naturality and sketches

commutes, but this is just the naturality diagram of β applied to the arrow
F (f ) : F (A) −→ F (A(cid:48)).

4.4.3 Deﬁnition The natural transformation Hα : H ◦ F −→ H ◦ G is de-
ﬁned by letting (Hα)A = H(αA) for an object A of A , that is the value of
H applied to the arrow αA.

To see that Hα thus deﬁned is natural requires showing that

H(F (A))

H(αA)

(cid:45)

H(G(A))

H(F (f ))

H(G(f ))

(cid:63)
H(F (A(cid:48)))

(cid:45)

H(αA(cid:48))

(cid:63)
H(G(A(cid:48)))

commutes. This diagram is obtained by applying the functor H to the nat-
urality diagram of α. Since functors preserve commutative diagrams, the
result follows.

Note that the proofs of naturality for βF and for Hα are quite diﬀerent.
For example, the second requires that H be a functor, while the ﬁrst works
if F is merely an object function.

The deﬁnitions of βF and Hα are quite diﬀerent, in fact. The ﬁrst is the
natural transformation whose value at an object A of A is the component of
β on the object F A while the value of the second is the result of applying
the functor H to the component αA (which is an arrow of B). Nevertheless,
we use similar notations. The reason for this is that their formal properties
are indistinguishable. In fact, even categorists quite commonly (though not
universally) distinguish them by writing βF but Hα. That notation emphasizes
the fact that they are semantically diﬀerent. The notation used here is chosen to
emphasize the fact that they are syntactically indistinguishable. More precisely,
the left/right mirror image of each of Godement’s rules given below is again a
Godement rule.

In a great deal of mathematical reasoning, one forgets the semantics of the
situation except at the beginning and the end of the process, relying on the
syntactic rules in the intermediate stages. This is especially true in the kind of
‘diagram chasing’ arguments so common in category theory. For that reason,
the notation we have adopted emphasizes the syntactic similarity of the two
constructions, rather than the semantic diﬀerence.

In Exercise 2, we give another, more sophisticated deﬁnition of βF and Hα
which shows that they can be thought of as semantically parallel, as well.

4.4 Godement calculus

119

4.4.4 There is a second way of composing natural transformations. The
naturality of β in Diagram (4.29) implies that for any object A of A , the
diagram

(H ◦ F )A

(Hα)A

(cid:45)

(H ◦ G)A

(βF )A

(βG)A

(4.30)

(cid:63)
(K ◦ F )A

(cid:63)
(K ◦ G)A

(cid:45)

(Kα)A

commutes. We deﬁne β ∗α : H ◦ F −→ K ◦ G by requiring that its component
at A be (Kα)A ◦ (βF )A, which of course is the same as (βG)A ◦ (Hα)A.

4.4.5 Proposition β ∗ α is a natural transformation.

Proof. We have that β ∗ α = Kα ◦ βF by deﬁnition of β ∗ α and Deﬁni-
tion 4.2.11. It is therefore a natural transformation by Proposition 4.2.12.

We usually call β ◦ α the vertical composite and β ∗ α the horizontal
composite. (Warning: Some authors use ◦ for the horizontal composite.)
One must keep careful track of the diﬀerence between them. Fortunately,
the notations do not often clash, since usually only one makes sense.

There is one case in which the two notations can clash. If A = B =
C and G = H, then β ◦ α : F −→ K, while β ∗ α : G ◦ F −→ K ◦ G. This
clash is exacerbated by the habit among many categorists of omitting the
composition circle and ∗, except for emphasis. We will often omit the ∗, but
not the circle. On the other hand, no confusion can possibly arise from the
overloading of the circle notation to include composition of arrows, functors
and natural transformations since their domains uniquely deﬁne what kind
of composition is involved.

4.4.6 Proposition Horizontal composition of natural transformations is
associative.

Proof. In the situation,

A

F
⇓ α

G

(cid:82)
(cid:181)

B

H
⇓ β

K

(cid:82)
(cid:181)

C

L
⇓ γ

M

(cid:82)
(cid:181)

D

(4.31)

we have that

γ ∗ (β ∗ α) = γKG ◦ L(βG ◦ Hα) = γKG ◦ LβG ◦ LHα

120

Diagrams, naturality and sketches

because L is a functor, while

(γ ∗ β) ∗ α = (γK ◦ Lβ)G ◦ LHα = γKG ◦ LβG ◦ LHα

by Deﬁnition 4.2.11.

4.4.7 Godement’s ﬁve rules There are thus several kinds of composites.
There is a composite of functors, vertical and horizontal composite of natural
transformations and the composite of a functor and a natural transformation
in either order (although the latter is in fact the horizontal composite of a
natural transformation and the identity natural transformation of a functor,
a fact we leave to an exercise). The possibilities are suﬃciently numerous
that it is worth the eﬀort to codify the rules.

Let A , B, C , D and E be categories; E : A −→ B, F1, F2 and F3 : B −→
C , G1, G2 and G3 : C −→ D, and H : D −→ E be functors; and α : F1 −→ F2,
β : F2 −→ F3, γ : G1 −→ G2, and δ : G2 −→ G3 be natural transformations.
This situation is summarized by the following diagram:

A

B(cid:45)E

F1

G1

F2

⇓ α

⇓ β

(cid:85)
C(cid:45)
(cid:184)

G2

⇓ γ

⇓ δ

(cid:85)
D(cid:45)
(cid:184)

F3

G3

E(cid:45)H

(4.32)

Then

G–1 (δ ◦ γ)(β ◦ α) = (δβ) ◦ (γα).
G–2 (H ◦ G1)α = H(G1α).
G–3 γ(F1 ◦ E) = (γF1)E.
G–4 G1(β ◦ α)E = (G1βE) ◦ (G1αE).
G–5 γα = (γF2) ◦ (G1α) = (G2α) ◦ (γF1).

The expression G1(β ◦ α)E in G–4 is not ambiguous because of Exer-
cise 1. G–1 is called the Interchange Law. It is the basis for the deﬁnition
of 2-category in Section 4.8.

4.4.8 Exercises

1. Show that, using the notation of the Godement rules, (G1α)E = G1(αE).
2. Show that in the Diagram (4.28), the composites βF and Hα are the
horizontal composites β ∗ idF and idH ∗α respectively.
3. a. Show (using Exercise 2) that Godement’s ﬁfth rule is an instance of
the ﬁrst.

b. Show that Godement’s fourth rule follows from the ﬁrst and the asso-

ciativity of horizontal composition.

4.5 Yoneda Lemma

121

4.5 The Yoneda Lemma and

universal elements

For an arbitrary category C , the functors from C to Set are special because
the hom functors Hom(C, −) for each object C of C are set-valued functors.
In this section, we introduce the concept of representable functor, the Yoneda
Lemma, and universal elements, all of which are based on these hom functors.
These ideas have turned out to be fundamental tools for categorists. They
are also closely connected with the concept of adjunction, to be discussed
later (note Theorem 13.3.2 and Proposition 13.3.6).

If you are familiar with group theory, it may be illuminating to realize
that representable functors are a generalization of the regular representation,
and the Yoneda embedding is a generalization of Cayley’s Theorem.

We have already considered set-valued functors as actions in Section 3.2.

4.5.1 Representable functors A functor from a category C to the cat-
egory of sets (a set-valued functor) is said to be representable if it is
naturally isomorphic to a hom functor; see 3.1.20. A covariant functor is
representable if it is naturally isomorphic to Hom(C, −) for some object C
of C ; in this case one says that C represents the functor. A contravariant
functor is representable if it is naturally isomorphic to Hom(−, C) for some
object C (and then C represents the contravariant functor).

We have already looked at one example of representable functor in some
detail in 4.3.10, where we showed that the set-of-nodes functor for graphs is
represented by the graph with one node and no arrows. The set-of-arrows
functor is represented by the graph with two nodes and one arrow between
them (Exercise 3).

4.5.2 The Yoneda embedding Let C be a category. There is a functor
Y : C op −→ Func(C , Set), the Yoneda functor, deﬁned as follows. Note
that Y must take an object of C to a functor and an arrow of C to a natural
transformation.

Y–1 For an object C of C , Y (C) = Hom(C, −).
Y–2 If f : D −→ C in C and A is an object of C , then the component
Y (f )A of Y (f ) : Hom(C, −) −→ Hom(D, −) is Hom(f, A) : Hom(C, A)
−→ Hom(D, A) (see 3.1.21).

Note that Y (C) is a covariant hom functor and that Y (f )A is a component
of a contravariant hom functor.

122

Diagrams, naturality and sketches

To see that Y (f ) is a natural transformation requires checking that this

diagram commutes for every arrow k : A −→ B of C :

Hom(D, A)
(cid:54)

Y (f )A

Hom(D, k)

(cid:45)

Hom(D, B)
(cid:54)
Y (f )B

Hom(C, A)

(cid:45)

Hom(C, k)

Hom(C, B)

To see that it commutes, start with h : C −→ A, an arbitrary element of the
lower left corner. The lower route takes this to k ◦ h, then to (k ◦ h) ◦ f . The
upper route takes it to k ◦ (h ◦ f ), so the fact that the diagram commutes
is simply a statement of the associative law. In a monoid, that this diagram
commutes is the statement that the function deﬁned by left multiplying by
a given element commutes with the function deﬁned by right multiplying by
another given element.

Y (f ) : Hom(C, −) −→ Hom(D, −) is the induced natural transforma-

tion corresponding to f .

The main theorem concerning Y is the following.

4.5.3 Theorem Y : C op −→ Func(C , Set) is a full and faithful functor.

The fact that Y is full and faithful is encapsulated in the following re-

markable corollary.

4.5.4 Corollary Every natural transformation

Hom(C, −) −→ Hom(D, −)

is given by composition with a unique arrow D −→ C. The natural transfor-
mation is an isomorphism if and only if the corresponding arrow D −→ C is
an isomorphism. In particular, if F : C −→ Set is represented by both C and
D, then C ∼= D.

This means that you can construct an arrow in a category by constructing
a natural transformation between hom functors. This is one of the most
widely used techniques in category theory.

Proof. Theorem 4.5.3 is an immediate consequence of the Yoneda Lemma
(4.5.8). We give a direct proof here. This proof is an excellent exercise in
manipulating natural transformations and hom sets.

Let f, g : D −→ C in C . The component

Y (f )C : Hom(C, C) −→ Hom(D, C)

4.5 Yoneda Lemma

123

of the natural transformation Y (f ) at C takes idC to f , and similarly Y (g)C
takes idC to g. Thus if f (cid:54)= g, then Y (f )C (cid:54)= Y (g)C, so that Y (f ) (cid:54)= Y (g).
Thus Y is faithful.

We must show that Y is full. Given φ : Hom(C, −) −→ Hom(D, −), we
get the required f : D −→ C by one of the basic tricks of category theory: we
deﬁne f = φC(idC). The component of φ at C is a function φC : Hom(C, C)
−→ Hom(D, C), so this deﬁnition makes sense.

To complete the proof, we must prove that if k : C −→ A is any arrow
of C , then φA(k) = k ◦ f : D −→ A. This follows from the fact that the
following diagram commutes by naturality of φ:

Hom(C, C)

Hom(C, k)

(cid:45)

Hom(C, A)

φC

(cid:63)

Hom(D, C)

φA

(cid:63)
Hom(D, A)

(cid:45)

Hom(D, k)

If you start in the northwest corner with idC, the upper route takes you to
φA(k) in the southeast corner, whereas the lower route takes you to k ◦ f ,
as required.

4.5.5 By replacing C by C op in Theorem 4.5.3, we derive a second Yoneda
functor J : C −→ Func(C op, Set) which is also full and faithful. For an object
C of C , J(C) = Hom(−, C), the contravariant hom functor. If f : C −→ D
in C and A is an object of C , then the component

J(f )A : Hom(A, C) −→ Hom(A, D)

of the natural transformation J(f ) : Hom(−, C) −→ Hom(−, D) is

Hom(A, f ) : Hom(A, C) −→ Hom(A, D)

The fact that J is full and faithful means that an arrow from A to
B of C can be uniquely deﬁned by giving a natural transformation from
Hom(−, A) to Hom(−, B). This statement is the dual of Corollary 4.5.4.
Such a natural transformation α : Hom(−, A) −→ Hom(−, B) has a com-
ponent αT : Hom(T, A) −→ Hom(T, B) for each object T of C . The eﬀect
of this is that you can deﬁne an arrow from A to B by giving a function
αT : Hom(T, A) −→ Hom(T, B) for each object T which prescribes a variable
element of B for each variable element of A (as described in 2.8.2), in such

124

Diagrams, naturality and sketches

a way that for each f : T (cid:48) −→ T , the diagram

Hom(T, A)

(cid:45)αT

Hom(T, B)

Hom(f, A)

Hom(f, B)

(cid:63)
Hom(T (cid:48), A)

(cid:45)

(cid:63)
Hom(T (cid:48), B)

αT (cid:48)
commutes. This can be summed up by saying, ‘An arrow is induced by
deﬁning its value on each variable element of its domain, provided that the
deﬁnition is natural with respect to change of parameters.’

4.5.6 Elements of a set-valued functor Corollary 4.5.4 says that any
natural transformation from Hom(C, −) to Hom(D, −) is given by a unique
arrow from D to C, that is, by an element of Hom(D, C) = Hom(D, −)(C).
Remarkably, the result remains true when Hom(D, −) is replaced by an
arbitrary set-valued functor.

Suppose F : C −→ Set is a functor and C is an object of C . An element
c ∈ F (C) induces a natural transformation from the representable functor
Hom(C, −) to F by the formula

f (cid:55)→ F (f )(c)

(4.33)

That is, if f : C −→ C(cid:48) is an element of Hom(C, C(cid:48)), the deﬁnition of functor
requires an induced function F (f ) : F (C) −→ F (C(cid:48)) and this function can be
evaluated at c ∈ F (C).

4.5.7 Proposition Formula (4.33) deﬁnes a natural transformation

Hom(C, −) −→ F

Proof. Let αC(cid:48) : Hom(C, C(cid:48)) −→ F (C(cid:48)) take f to F (f )(c) for c ∈ F (C). We
must show that for any g : C(cid:48) −→ B,

Hom(C, C(cid:48))

(cid:45)αC(cid:48)

F (C(cid:48))

Hom(C, g)

F (g)

(4.34)

(cid:63)
Hom(C, B)

(cid:63)
F (B)

(cid:45)

αB

commutes. We have, for f ∈ Hom(C, C(cid:48)),

αB(Hom(C, g)(f )) = αB(g ◦ f ) = F (g ◦ f )(c)

= F (g)(F (f )(c)) = F (g)(αC(cid:48)(f ))

as required.

4.5.8 Theorem (Yoneda Lemma) Formula (4.33) deﬁnes a one to one
correspondence between elements of F (C) and natural transformations

4.5 Yoneda Lemma

125

Hom(C, −) −→ F

Proof. Suppose that c and c(cid:48) are diﬀerent elements of F (C). Then the nat-
ural transformation corresponding to c takes idC to c whereas the one cor-
responding to c(cid:48) takes idC to c(cid:48). Thus the mapping of the Yoneda Lemma is
injective.

Suppose β : Hom(C, −) −→ F is a natural transformation. Then we have
βC : Hom(C, C) −→ F (C). Let c = βC(idC) ∈ F (C). For any f : C −→ C(cid:48),
the naturality of β gives that

βC(cid:48)(Hom(C, f )(idC)) = F (f )(βC)(idC)

The left hand side is βC(cid:48)(f ) and the right hand side is F (f )(c). Thus β is
the natural transformation given by Formula (4.33), so that the mapping of
the Yoneda Lemma is surjective.

4.5.9 Deﬁnition Let F : C −→ Set be a functor and let c be an element of
F (C) for some object C of C . If the natural transformation from Hom(C, −)
to F induced by c is an isomorphism, then c is a universal element of F .

The existence of a universal element means that F is representable (see 4.5.1).

The converse is also true because a natural isomorphism α : Hom(C, −) −→ F
is, from the Yoneda lemma, induced by a unique element c of F (C) and by
deﬁnition α is an isomorphism if and only if c is universal.

The unique element c can be calculated using the following fact.

4.5.10 Proposition Let α : Hom(C, −) −→ F be a natural isomorphism.
The unique element c ∈ F (C) inducing α is αC(idC).
Proof. For an arbitrary f : C −→ C(cid:48), αC(cid:48)(f ) = F (f )(αC(idC)) because this
diagram must commute (chase idC around the square):

Hom(C, C)

(cid:45)αC

F (C)

Hom(C, f )

F (f )

(cid:63)
Hom(C, C(cid:48))

(cid:63)
F (C(cid:48))

(cid:45)

αC(cid:48)

Then, by Formula (4.33), αC(idC) must be the required unique element c.

A detailed example of the use of this construction is in the proof of

Proposition 5.2.14.

126

Diagrams, naturality and sketches

4.5.11 The deﬁnition of universal element can be reworded in elementary
terms using Formula (4.33), as follows.

4.5.12 Proposition Let F : C −→ Set be a functor, C an object of C
and c an element of F (C). Then c is a universal element of F if and only if
for any object C(cid:48) of C and any element x ∈ F (C(cid:48)) there is a unique arrow
f : C −→ C(cid:48) of C for which x = F (f )(c).

Proof. If c is a universal element then the mapping (4.33) must be an iso-
morphism, hence every component must be bijective by Theorem 4.2.20. This
immediately ensures the existence and uniqueness of the required arrow f .
Conversely, the existence and uniqueness of f for each C(cid:48) and x ∈ F (C(cid:48))
means that there is a bijection αC(cid:48) : Hom(C, C(cid:48)) −→ F (C(cid:48)) for every C(cid:48)
which takes f : C −→ C(cid:48) to F (f )(c). By Proposition 4.5.7, these are the
components of a natural transformation, which is therefore a natural iso-
morphism by Theorem 4.2.20.

In the case of a functor F : C op −→ Set, c in F (C) is a universal element
if for any object C(cid:48) of C and any element x ∈ F (C(cid:48)) there is a unique arrow
f : C(cid:48) −→ C for which x = F (f )(c).

4.5.13 Corollary If c ∈ F (C) and c(cid:48) ∈ F (C(cid:48)) are universal elements, then
there is a unique isomorphism f : C −→ C(cid:48) such that F (f )(c) = c(cid:48).

The proof is left as Exercise 10.
Universal elements are considered again in Proposition 13.3.6. The ex-
position in [Mac Lane, 1971] uses the concept of universal element (deﬁned
in the manner of the preceding proposition) as the central idea in discussing
representable functors and adjunction.

4.5.14 Exercises

1. Show that a representable functor preserves terminal objects but not nec-
essarily initial objects.

2. Show that HomSet(1, −) is naturally isomorphic to the identity functor
on Set. (‘A set is its set of global elements.’ In terms of 4.5.1 this says that
a singleton set represents the identity functor on Set.)

3. Show that the arrow functor A : Grf −→ Set of 3.1.9 is represented by
the graph 2 which is pictured as

(Compare Exercise 10 of Section 4.3.)

1

2(cid:45)e

4.6 Linear sketches

127

4. Show that the set of objects of a small category is ‘essentially the same
thing’ as the set of global elements of the category (as an object of Cat),
and translate this into a natural isomorphism following the pattern of 4.3.10.

5. Is the set of arrows of a small category the object part of a functor? If it
is, is it representable?

6. Prove that any set-valued functor F : C −→ Set is naturally isomorphic
to a functor for which if C and D are distinct objects of C , then F (C) and
F (D) are disjoint sets.

7. Let D : Set −→ Set be the functor for which for a set A, D(A) = A × A,
and for a function f : A −→ B, D(f ) : A × A −→ B × B is the function
deﬁned by D(f )(a1, a2) = (f (a1), f (a2)). Show that D is representable and
ﬁnd a universal element for D.

8. Show that the second Yoneda embedding J deﬁned in 4.5.5 is full and
faithful.
9.† Formulate carefully and prove that the equivalence in the Yoneda Lemma
is natural in both C and F .
10. Verify the claim made in 4.5.13 that if c ∈ F (C) and c(cid:48) ∈ F (C(cid:48)) are
both universal elements of the functor F : C −→ Set, then there is a unique
isomorphism f : C −→ C(cid:48) such that F (f )(c) = c(cid:48).

4.6 Linear sketches (graphs with diagrams)

Speciﬁcations in mathematics and computer science are most commonly ex-
pressed using a formal language with rules spelling out the semantics. How-
ever, there are other objects in mathematics intended as speciﬁcations that
are not based on a formal language. Many of these are tuple-based; for ex-
ample the signature of an algebraic structure or the tuple specifying a ﬁnite
state machine.

A sketch is another kind of formal abstract speciﬁcation of a mathemat-
ical structure; it is based on a graph rather than on a formal language or
tuple. The semantics is often a functor; in other contexts it is a structure
generalizing Goguen’s initial algebra semantics.

Each sketch generates a (categorical) theory; this theory is a category

that in a strong sense contains all the syntax implied by the sketch.

4.6.1 Linear sketches We construct a hierarchy of types of sketches here
and in Chapters 7, 8 and 10. Each new type uses additional categorical
constructions to provide more expressive power than the preceding types.

What we can do now is describe a very simple type of structure using
‘linear’ sketches. It can describe multisorted algebraic structures with only

128

Diagrams, naturality and sketches

unary operations. If you are not familiar with multisorted algebraic struc-
tures, it will not matter.

4.6.2 Deﬁnition A linear sketch S is a pair (G , D) where G is a graph
and D is a collection of diagrams in G . Because of the motivating example
of algebraic structures, the arrows of the graph of a sketch (not just a linear
sketch) are often called operations of the sketch.

4.6.3 Deﬁnition A model of a linear sketch S in a category C is a
model (graph homomorphism) M : G −→ C such that whenever D : I −→ G
is a diagram in D, then M ◦ D is a commutative diagram in C . The diagrams
represent the equations which have to be true in all models.

We write M : S −→ C for such a model. This use of the same symbol
to denote both the sketch homomorphism and the graph homomorphism is
a bit of notational overloading that in practice is always disambiguated by
context. The collection of all models of S in C is denoted Mod(S , C ).

A model of a sketch S in Set is (among other things) a set indexed by
the nodes of the graph of S as discussed in 2.6.11. If M is a model and c is
a node of the graph, an element of M (c) is an element indexed by c, or an
element of type c.

4.6.4 Deﬁnition A homomorphism of models of a linear sketch S ,
both models in the same category C , is a natural transformation between
the models. For given S and C , the models therefore form a category with
natural transformations as arrows; this category is a full subcategory of the
category of all graph homomorphisms from G to C (which in general do not
take the diagrams in D to commutative diagrams).

4.6.5 Example Any category E can be made into a linear sketch called
the underlying linear sketch of E , denoted U (E ) (concerning this nota-
tion, see 4.6.10 below), by taking for the diagrams the collection of all com-
mutative diagrams in the category. A model of the underlying linear sketch
E in some category C is the same as a functor on the original category: on
the one hand, any functor takes any commutative diagram to a commuta-
tive diagram and so is a model. On the other hand a model M : S −→ C of
the underlying linear sketch S of E preserves in particular all commutative
diagrams of the form

A
g ◦ f(cid:64)

(cid:64)(cid:82)

B(cid:45)f
g(cid:161)

(cid:161)(cid:170)

C

(4.35)

4.6 Linear sketches

129

and so preserves composition as well as every commutative diagram consist-
ing of a single node and no arrows, and so preserves identities (see 4.1.6).

4.6.6 Example The linear sketch for u-structures has the graph with one
node and one arrow as its graph, and no diagrams.

4.6.7 Example The construction in 4.2.7 gives the sketch for graphs.
Its graph is

n

(4.36)

and it has no diagrams.

a

s
−−→−−→
t

4.6.8 Example We now consider an example of a linear sketch which has
diagrams. Suppose we wanted to consider sets with permutations as struc-
tures. This would be a u-structure (S, u) with u a bijection. We can force u
to go to a bijection in Set-models by requiring that it have an inverse. Thus
the sketch P of sets with permutations has as graph the graph G with one
node e and two arrows u and v, together with this diagram D:

based on the shape graph

e

u
−−→←−−
v

e

i

x
−−→←−−
y

j

(4.37)

(4.38)

A model M of this sketch in Set must have M (e) a set, M (u) and M (v)
functions from M (e) to itself (since D(i) = D(j) = e), and because Dia-
gram (4.37) must go to a commutative diagram, it must have

M (u) ◦ M (v) = M (v) ◦ M (u) = idM (e)

This says that M (u) and M(v) are inverses to each other, so that they are
permutations. Note that a model in any category is an object of that category
together with an isomorphism of the object with itself and the inverse of that
isomorphism.

If we had used as the only diagram the diagram with one node e and both
arrows u and v, the result would have been a sketch in which any model M
had the property that M (u) and M (v) are the identity.

130

Diagrams, naturality and sketches

4.6.9 Example Suppose we wanted to have a linear sketch for graphs
which have at least one loop at every node. We could try the following con-
struction, which contains a mild surprise. The sketch has the graph (4.19),
page 102 as its graph, with arrows s : N −→ A and idN : N −→ N added. The
diagrams are

idN

(cid:82)

N

(4.39)

and

N

A(cid:45)s

N

A(cid:45)s

(cid:64)
idN

(cid:64)

(cid:64)

(cid:64)(cid:82)

source

(cid:63)
N

(cid:64)
idN

(cid:64)

target

(4.40)

(cid:64)

(cid:64)(cid:82)

(cid:63)
N

In a model M in sets, if n is a node, that is, n ∈ M (N ), then M (s)(n) is
an arrow. The commutativity of Diagram (4.39) forces M (idN ) to be idM (N )
(see 4.1.6), and the commutativity of the diagrams (4.40) forces the source
and target of M (s)(n) to be n, so that M (s)(n) is a loop on n.

The surprise is that a homomorphism α : M −→ M (cid:48) of models of this
sketch must take the particular loop M (s)(n) to M (cid:48)(s)(αN (n)). Of course,
any homomorphism of graphs will take the loop M (s)(n) to some loop on
αN (n), but our homomorphisms are stricter than that. So what we really
have are graphs with a distinguished loop at every node and homomorph-
isms which take distinguished loops to distinguished loops. These are called
reﬂexive graphs. A node in a reﬂexive graph may have other loops but they
are not part of the given structure.

If you want a sketch for graphs which have a loop on every node, but
not a distinguished loop (so that a homomorphism takes the loop on n to
some loop on αN (n), but it does not matter which one), you will have to
wait until we can study regular sketches in Section 10.4.

4.6.10 Homomorphisms of linear sketches A homomorphism of lin-
ear sketches from S = (G , D) to S (cid:48) = (G (cid:48), D (cid:48)) is a graph homomorphism
φ : G −→ G (cid:48) with the property that if D : I −→ G is a diagram in D, then
φ ◦ D : I −→ G (cid:48) is a diagram in D (cid:48). It is easy to check that this deﬁnition
makes linear sketches and their homomorphisms into a category.

Note that here we are deﬁning homomorphisms between possibly diﬀerent
sketches, whereas in Deﬁnition 4.6.4 we deﬁned homomorphisms between two
models of a sketch.

If F : C −→ C (cid:48) is a functor between categories, the underlying linear
sketch homomorphism U (F ) : U (C ) −→ U (C (cid:48)) is F regarded as a homo-

4.6 Linear sketches

131

morphism of graphs. Since it takes any commutative diagram in C to a
commutative diagram in C (cid:48), it is a homomorphism of linear sketches.

We have already used the symbol U (E ) to denote the underlying graph
of a category E in 3.1.10. Here, we use it to denote the underlying linear
sketch. In this text, we disambiguate such notation by using phrases such
as ‘the underlying graph U (E )’. In a situation where one needed frequently
to refer to several diﬀerent underlying functors from the same category, one
could introduce heavy notation such as U Cat
Grf .

4.6.11 The theory of a linear sketch You can reverse 4.6.5: given a
linear sketch S , there is a category Th(S ), the theory of S , which has
a universal model M0 of S in this sense: M0 : S −→ U (Th(S )) is a
model, and for any other model M : S −→ U (C ), there is a unique functor
F : Th(S ) −→ C such that U F ◦ M0 = M . Since U F is a model of the
underlying sketch of the category Th(S ) (see 4.6.5), M0 induces a bijection
between models of S and models of its theory (functors from Th(S ) to
Set). This bijection is in fact part of an equivalence of categories between
Mod(S , Set) and the functor category Func(Th(S ), Set).

Th(S ) satisﬁes the following requirements:

LT–1 Every arrow of Th(S ) is a composite of arrows of the form M0(a) for

arrows a of S .

LT–2 M0 takes every diagram of S to a commutative diagram in Th(S ).

4.6.12 Construction of the theory of a linear sketch Let S be a
linear sketch. The idea behind the construction of Th(S ) is: ‘Freely compose
the arrows of G and impose the diagrams as equations.’ Formally, begin
with the free category F (G ) generated by G and construct Th(S ) and a
functor Q : F (G ) −→ Th(S ) which make all the diagrams in D commute as
described in 4.1.13. The universal model M0 : G −→ U (Th(S )) is U Q ◦ ηG
(see 3.1.14); it takes each node to itself and each arrow to its congruence
class in Th(S ).

That M0 has the property claimed in 4.6.11 follows by considering this

diagram for a given model M : G −→ U C :

G

U F G(cid:45)ηG
(cid:64)
M

(cid:64)

(cid:64)

(cid:64)(cid:82)

U (cid:99)M
(cid:63)
U C

(cid:45)Q

F G

Th(S )
(cid:161)
F0

(cid:161)

(cid:99)M

(cid:161)

(cid:161)(cid:170)

(cid:63)
C

(4.41)

For a given M , it follows by Proposition 3.1.15 that there is a unique func-
tor (cid:99)M for which the left triangle commutes. Then by Proposition 3.5.4 (see

132

Diagrams, naturality and sketches

also 4.1.13) there is a unique functor F0 : Th(S ) −→ C making the right
hand triangle commute. Apply U to the right hand triangle, put them to-
gether and let M0 = U Q ◦ ηG . Then we have a commutative triangle:

G

(cid:64)
M

(cid:64)

M0

(cid:45)

U Th(S )
(cid:161)
U F0

(cid:161)

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

U C

(4.42)

This shows the existence and we leave the uniqueness to the reader.

The construction of a semantics functor for a functional programming
language illustrated in 3.5.9 is a special case of the construction just given.

4.6.13 Examples The theory which is generated by the underlying linear
sketch of a category is isomorphic to the category itself (Exercise 3). The
sketch for u-structures (see 4.2.5 and 4.6.6) generates a category with one
node u0, its identity arrow, and arrows e, e ◦ e, e ◦ e ◦ e, and so on, all
diﬀerent because there are no equations to make them the same. In other
words, it has one arrow en for each natural number n.

The theory for the sketch for graphs (its graph is 1.3.9 and it has no
diagrams) has only two arrows besides those in the graph 1.3.9, namely the
identity arrows in a and n. That is because the two arrows of the graph do
not compose with each other.

The sketch for permutations in 4.6.8 is more complicated. It has one node
e and arrows un for all positive and negative integers n. This is essentially
because v must be u−1 in the theory; see 4.7.13 for more details.

The reader may wonder why the term ‘linear sketch’ is appropriate. One way
of thinking of linear sketches is that they are exactly the sketches for which the
following are true:

(i) If M1 and M2 are models in the category of sets, then there is a model
M1 +M2 deﬁned by setting (M1 +M2)(a) = M1(a)+M2(a), a ∈ G0(S ).
(S + T is the disjoint union of sets S and T .)

(ii) If M is a model and X is a set, there is a model X × M deﬁned by

setting (X × M )(a) = X × M (a), a ∈ G0.

The linear sketches with constants that we will consider in Section 4.7 below
lack these ‘linearity’ properties. They should perhaps be called aﬃne sketches.
For the reader familiar with equational theories we observe that linear sketches
have only unary operations while linear sketches with constants have, in addi-
tion, nullary operations.

4.7 Linear sketches with constants

133

4.6.14 Exercises

1. Find a linear sketch S for which Mod(S , Set) is isomorphic to Set.

2. Describe a linear sketch whose models in Set are sets S with two functions
from S to S which commute with each other on composition.

3. Prove that if a category C is regarded as a linear sketch as in 4.6.5, then
Th(C ) is isomorphic to C .

4. Let M and N be models of the sketch in 4.6.8. Show that f : M (e)
−→ N (e) is (the only component of) a homomorphism of models if and only
if f ◦ M (u) = N (u) ◦ f .

5. Describe the theory of the linear sketch whose graph is

with diagram

0

u

0

u
−−→←−−
v

1

1(cid:45)u

v

(cid:63)
0

(cid:63)
1

(cid:190)

u

(4.43)

(4.44)

4.7 Linear sketches with constants:

initial term models

In this section, we describe a semantics for linear sketches which is essentially
a special case of Goguen’s initial algebra semantics. We will treat a version
equivalent to the general case in Section 7.6. We construct a speciﬁc model
of the sketch in Set by using the ingredients of the sketch, in a similar spirit
to mathematical logic wherein models of a theory are constructed using the
expressions in the language.

4.7.1 Deﬁnition A model of a sketch in a category C is called initial if
it has exactly one arrow (natural transformation) to every model in C .

Thus an initial model is an initial object in the category of models, as
the name suggests. Any two initial objects of any category are isomorphic
by a unique isomorphism, so initial models in a given category are unique
up to isomorphism.

In the case of a linear sketch, to describe the initial model in the category
of sets is easy; it is the model M : S −→ Set for which M (a) = ∅ for every

134

Diagrams, naturality and sketches

node a of S . When we discuss further sketches we will see that the initial
models will be more interesting. At this point, we have to complicate things
a bit to get interesting models.

4.7.2 Deﬁnition By a linear sketch with constants we mean a triple
S = (G , D, C) where (G , D) is a linear sketch and C is a collection of con-
stants indexed (as in 2.6.11) by the set of nodes of G . We let type : C −→ G0
be the indexing function, where G0 denotes the set of nodes of G . We will
not formalize this further because we will have a more systematic way of
doing this in Chapter 7. In particular, we could discuss models on categories
other than that of sets, but there is no purpose in doing so.

The sketch (G , D) is called the underlying linear sketch of the linear

sketch with constants.

4.7.3 Deﬁnition A model of a linear sketch with constants in the cate-
gory of sets is a model M : (G , D) −→ Set together with a function M : C
−→

a∈G0 M (a) such that for x ∈ C, M (x) ∈ M (type(x)).

(cid:83)

(Note that we have overloaded M , and that M need not be injective.)
Thus a model of a linear sketch with constants is a model of the underlying
linear sketch together with elements chosen in the models of various types.
The existence of the constants means that the values need no longer be

empty. In particular, the initial models may be interesting.

4.7.4 Example We give a somewhat arbitrary example which illustrates
what happens. Let us add three constants to the sketch for graphs, f of type
a and x and y of type n. A set model of this sketch with constants will be a
model M in Set of the sketch for graphs – in other words, a graph – with a
distinguished arrow M (f ) and two distinguished nodes M (x) and M (y). It
may happen that M (x) = M (y) and there is no requirement that M (x) or
M (y) be the source or target of M (f ).

4.7.5 Deﬁnition A homomorphism of models of a linear sketch with
constants is a natural transformation between two models of the sketch that
takes the values of the constants in the ﬁrst model to the values in the second.

In other words, if M1 and M2 are models and φ : M1 −→ M2 is a homo-
morphism of models of the underlying linear sketch, then to be a homo-
morphism of models of the linear sketch with constants it must also sat-
isfy the requirement that for any x ∈ C of type a, φa(M1(x)) = M2(x).
Thus in 4.7.4, a homomorphism α : M1 −→ M2 of models of that sketch
with constants has to have αA(M1(f )) = M2(f ), αN (M1(x)) = M2(x), and
αN (M1(y)) = M2(y).

4.7 Linear sketches with constants

135

4.7.6 Term models A model M of a sketch with constants is called a
term model if for every node a of the underlying graph, every element of
M (a) is reachable by beginning with constants and applying various oper-
ations (arrows of the sketch). The constants you begin with do not have to
be of type a, but the ﬁnal operation will, of course, have to be one that
produces an element of type a. The signiﬁcance of this condition from the
computational point of view is that elements that cannot be produced in
this way might as well not be there.

4.7.7 Example Let us consider the linear sketch of u-structures with one
constant which we will call zero. Let the graph have node n and call the only
arrow succ. There are no diagrams. As this nomenclature suggests, one model
of this sketch in Set is the natural numbers with the successor operation; the
constant is 0. Other models are the integers and the integers modulo a ﬁxed
number k (in both cases, take the successor of x to be x + 1). However, the
natural numbers are the unique (up to unique isomorphism) initial model.
To see this, suppose M is any other model. Let us use the same letter
M to denote M (n) since there are no other nodes (common practice when
the sketch has only one node). Also, let t : M −→ M denote the value of M
at succ and m0 the value at zero. We let N, succ and 0 denote the values
of these things in the natural numbers. To show that N is the initial model
we must deﬁne a natural transformation f : N −→ M and show that it is the
only one.

Deﬁne f as follows: let f (0) = m0, as required if f is to be an arrow
between linear sketches with constants. Then since f must commute with
succ, we must have that f (1) = t(m0), f (2) = t(t(m0)), and so on. This
deﬁnes f inductively on the whole of N. It is clearly unique and immediate
to see that it is an arrow between models.

In Section 5.5, we base the deﬁnition of natural numbers object in an

arbitrary category on this sketch.

4.7.8 Initiality and induction Since N is the initial model for the linear
sketch of u-structures with one constant, it follows that, as a u-structure, N
has no proper substructures (Proposition 2.8.7). (Of course it does have
proper substructures for example as a semigroup on addition.) This can be
reworded as follows: If S is a subset of N with the property that 0 ∈ S
and for any x ∈ S also succ(x) ∈ S, then S = N. This is the principle of
mathematical induction.

In general, an initial model of any sketch has no proper subobjects and
so produces a principle of structural induction appropriate to that type of
structure. (See 8.1.8.)

136

Diagrams, naturality and sketches

4.7.9 Example The set of all integers is a model but not a term model of
the linear sketch of u-structures with one constant. For imagine you have a
computer that can store integers, but the only operation that can be carried
out on them is that of increment (successor). Suppose, further, that the
only natural number whose existence you are certain of is 0. Then you can
certainly produce, in addition, 1, 2, . . ., but no negative numbers. Therefore,
they may as well not be there. You can get them by, for example, adding a
decrement operation, but as it stands they are inaccessible. They are what
J. Goguen and J. Meseguer have called ‘junk’.

4.7.10 Example The set Zk of natural numbers (mod k) is a term model
of the sketch of 4.7.7, but not an initial model. For example, there is no arrow
from the natural numbers (mod k) to the natural numbers. In the ﬁrst, the
successor of k − 1 is 0, while in the second it is nonzero. Thus no arrow could
preserve successor at that point. What has happened here is that the model
satisﬁes an additional equation k = 0 not required by the diagrams. This is
an example of what Goguen and Meseguer call ‘confusion’.

4.7.11 Construction of initial term models Linear sketches with con-
stants always have initial models. When the sketch is ﬁnite, an initial model
can always be constructed recursively as a term model. (‘Finite’ means ﬁnite
number of nodes and arrows.) We now give this construction.

Let S = (G , D, C) be a linear sketch with constants. We deﬁne a model
I : S −→ Set recursively as the model constructed by the following require-
ments I–1 through I–3. (I–1 through I–3 can be see to deﬁne an operator,
with the model I as a ﬁxed point of the operator.)

The elements of I(a) for a node a of G are congruence classes of terms
of G (composable strings of arrows, including constants, of G ); [x] denotes
the congruence class of a term x by the congruence relation generated by the
relation ∼ constructed recursively in the model. By ‘congruence relation’, we
mean congruence on the free category generated by G as deﬁned in 3.5.1. In
particular, if (g, f ) and (g(cid:48), f (cid:48)) are both composable pairs and [f ] = [f (cid:48)] and
[g] = [g(cid:48)], then [g ◦ f ] = [g(cid:48) ◦ f (cid:48)].

I–1 If a is a node of G and x is a constant of type a, then [x] ∈ I(a).
I–2 If f : a −→ b is an arrow of G and [x] is an element of I(a), then [f x] ∈
I(b) and I(f )[x] = [f x]. (Note that this constructs both an element and
a value of the function I(f ) simultaneously.)

I–3 If (f1, . . . , fm) and (g1, . . . , gk) are paths in a diagram in D, both going

from a node labeled a to a node labeled b, and [x] ∈ I(a), then

(If1 ◦ If2 ◦ . . . ◦ Ifm)[x] = (Ig1 ◦ Ig2 ◦ . . . ◦ Igk)[x]

in I(b).

4.7 Linear sketches with constants

137

4.7.12 By ‘the model constructed by’ these requirements, we mean that

(i) no element is in I(a) except congruence classes of the terms constructed

in I–1 and I–2, and

(ii) two terms are equivalent if and only if they are forced to be equivalent

by the congruence relation generated by I–3.

Requirement (i) means that the models have no elements not nameable
in the theory (‘no junk’) and (ii) means that elements not provably the same
are diﬀerent (‘no confusion’). Concerning (ii), see Exercise 2. It follows from
requirement (ii) that if [x] = [y] in I(a) and f : a −→ b is an arrow of G , then
[f x] = [f y] in I(b).

Note that the models in 4.7.10 have terms giving the same element which

are not forced to be equivalent by I–3.

4.7.13 Example Let us work out the initial term model of the sketch
from 4.6.8 with one constant called x added. Since the sketch has only one
node, the model has only one type. Thus in this case, there is only one set,
call it S, and the arrows of the sketch lead to functions from S to S.
Then S has elements in accordance with the following rules:

Mod–1 There is an element [x] ∈ S.
Mod–2 If [y] ∈ S, then there are elements [uy], [vy] ∈ S.
Mod–3 If [y] = [z], then [uy] = [uz] and [vy] = [vz].
Mod–4 For any [y] ∈ S, [uvy] = [vuy] = [y].

It is clear that the set of all ‘words’ [w1w2 . . . wkx], where each wi is either
u or v, satisﬁes the ﬁrst two rules above. In order to satisfy all four, we have
to impose the equalities they force. In order to gain some insight into this,
let us calculate some of the elements of S.

We observe that there must be elements

[x0] = [x], [x1] = [ux], [x2] = [uux], . . . , [xn] = [uu · · · u
(cid:124) (cid:123)(cid:122) (cid:125)
n copies

x]

as well as elements we will denote

[x−1] = [vx], [x−2] = [vvx], · · · , [x−n] = [vv · · · v
(cid:124) (cid:123)(cid:122) (cid:125)
n copies

x]

We ﬁrst explain why these elements exhaust S. We will not give a formal
proof, but let us see which element is represented by an element chosen
more or less at random, [y] = [uvuvuuvux]. Since [vux] = [x], we have that
[y] = [uvuvuux] = [uvuvx2]. Since [uvx2] = [x2], it follows that [y] = [uvx2]
and then [y] = [x2], by another application of the same identity.

138

Diagrams, naturality and sketches

This kind of reasoning can be used to show that any application of u’s
and v’s to [x] gives the element [xk] where k is the number of u’s less the
number of v’s.

In particular, [uxk] = [xk+1] and [vxk] = [xk−1] so that the set {[xk] |
−∞ < k < ∞} is carried into itself by both u and v. It contains [x] = [x0]
and so must be all of S.

There remains the question of all the [xk] being distinct; that is whether
or not there are any identities among the [xk]. There is a standard way of
resolving this question: if there is an equation among two combinations of
arrows from the sketch, that equation must hold in every model. Thus if the
equation fails in any one model, it cannot be a consequence of the identities
in the sketch. In this case, there is an easy model, namely the set Z of all
integers. In the set Z, we let u act by addition of the number 1 and v act by
subtracting 1. Then any combination of actions by u and v is just addition of
k, the diﬀerence between the number of u’s and v’s (which may be negative).
The discussion above suggests how to construct a bijection between S
and Z which is an isomorphism of models. We must choose an element to
correspond to [x]. A plausible, but by no means necessary, choice is to corre-
spond [x] to 0. If we do that then we must correspond [x1] = [ux] to [u0] = 1,
[x2] = [uux] to [uu0] = 2 and so on to correspond [xk] to k, for k > 0. For
k < 0, the argument is similar, replacing u by v, to show that we correspond
[xk] to k in that case as well.

The isomorphism just constructed takes each [xk] to the integer k, which
implies that if k (cid:54)= k(cid:48), then [xk] (cid:54)= [xk(cid:48)]. Thus S consists of precisely the
distinct classes [xk], one for each integer k ∈ Z.

4.7.14 Example The initial term model for the sketch for graphs with
two constants x and y of type n and one constant f of type a given in
Example 4.7.4 can be constructed using the method of the preceding example
(but it is much easier). The result is a model I with

I(n) = {x, y, source(f ), target(f )}

and I(a) = {f }. It is a graph with four nodes and an arrow between two of
them.

4.7.15 Given the construction in 4.7.11 and any Set model M of the same
sketch, the unique homomorphism α : I −→ M is constructed inductively as
follows:

M–1 If x is a constant of type a, then αa[x] = M (x).

4.7 Linear sketches with constants

139

M–2 If f : a −→ b in G and [x] ∈ I(a), then αb([f x]) = M (f )([M (x)]).

It is a straightforward exercise to show that this is well deﬁned and is a

homomorphism of models. It is clearly the only possible one.

The construction in 4.7.11 can be seen as the least ﬁxed point of an operator
on models of the sketch (without the constants) in the category of sets and
partial functions. To any such model M , the operator adjoins an element f (x)
to M (b) for any arrow f : a −→ b and any element x ∈ M (a) for which M (f )(x)
is not deﬁned. It forces f (x) to be the same as some other element of M (b)
if the diagrams force that to happen (we leave the formal description of this
to you). To get the model for a particular set of constants, you start with the
model obtained by applying only I–1 (so that the sorts have only constants in
them and all the arrows have empty functions as models). The least ﬁxed point
of this operator is the model in 4.7.11, up to isomorphism.

4.7.16 Properties of model categories We have seen that the cate-
gory of models of a linear sketch with constants always has an initial object.
The fact that the category of nonempty semigroups and semigroups homo-
morphisms does not have an initial object (see 2.7.17) thus means that that
category is not the category of models of a linear sketch with constants.
This is our ﬁrst example of a theorem in model theory of a very typical
sort, saying that the category of models of a certain kind of sketch or theory
has to have certain properties, so that if a category C does not have one of
those properties, it is not the category of models of a sketch of that kind.
Generally, the more expressive the sketch, the fewer restrictions are imposed
on the possible categories of models. Such theorems are covered in detail
in [Barr and Wells, 1985] and [Ad´amek and Rosiˇcky, 1994].

4.7.17 Free models Let S be a ﬁxed linear sketch with just one node.
With each set C we can associate a linear sketch with the set C of constants.
Let us call it S (C). Let F (C) denote an initial model of S (C). A model
of S (C) is a model M of S together with a function C −→ M . Here, as
above, we will use the name of the model to denote the value at the single
node of the sketch. To say that F (C) is an initial model of S (C) is to say
that given any model M of S together with a function C −→ M , there is a
unique arrow F (C) −→ M in the category of models for which

C

(cid:161)

(cid:161)(cid:170)
U F (C)

(cid:64)
(cid:64)(cid:82)
U M(cid:45)

commutes. This property is summarized by saying that F (C) is the free
model of S generated by C. Note the similarity with Proposition 3.1.15.
Freeness is given a uniﬁed treatment in Deﬁnition 13.2.1.

140

Diagrams, naturality and sketches

4.7.18 This notion of free models can be generalized to the case of many
nodes. We indicate brieﬂy how this can be done. Let S be a linear sketch
and G0 be the nodes of its graph. By a G0-indexed set, we mean a set C
together with a function C −→ G0 (see 2.6.11). Given any such set we can
form a sketch S (C) which is the linear sketch with the set C of constants
with the given function as type function. An initial model of this sketch is
called the free model generated by the G0-indexed set C.

Example 4.7.7 can now be seen as describing the free u-structure with
one constant. Another example is the free graph on two nodes and one arrow.
As we saw in Example 4.7.14, it has four nodes, and one arrow connecting
two of them.

We describe sketches with more expressive power in Chapters 7, 8 and 10.

4.7.19 Exercises

1. Find the initial term model of the linear sketch of Exercise 5 of Section 4.6
with two constants added, x of type 0 and y of type 1.

2. Show that requirement (ii) of 4.7.12 is equivalent to the following state-
ment: two terms in the model I are equivalent if and only if every model of
S takes them to the same function.

3. Show that if S is any linear sketch with constants, then Mod(S , Set)
has a terminal object.

4.8 2-categories

The category Cat of small categories and functors is a category, but it has
more structure than a category since between two functors with the same
domain and the same codomain there are natural transformations. A 2-
category C can be thought of as a category Cb (its base category) with in
addition ‘maps from arrows to arrows’ called 2-cells that have many of the
properties of natural transformations, for example the interchange law.

We give a deﬁnition here (4.8.1, 4.8.3, 4.8.7) that in eﬀect deﬁnes a 2-
category without assuming the existence of the base category, which is then
discovered as part of the structure; then we give a second more conceptual
deﬁnition (4.8.10) that expresses a 2-category as a kind of ‘enriched’ category.
These deﬁnitions follow [Power and Wells, 1992].

The most accessible introduction to 2-categories is that of [Kelly and
Street, 1973]; much more is in [Gray, 1974] and [Kelly, 1982a]. [Baez, 1997]
is an exposition with many references to the literature of current work on
generalizations to n-categories and even further. Applications to computer
science are discussed in [Seely, 1987b], [Gray, 1988], [Ji-Feng and Hoare,

4.8 2-categories

141

1990], [Power, 1990b], [Power and Wells, 1992] and [Corradini and Gadducci,
1997].

4.8.1 Deﬁnition of 2-category, part I A 2-category C consists of three
sets C0, C1 and C2 subject to certain requirements listed in TC–1 through
TC–6 below. We ﬁrst establish some notation.

(a) The elements of Ci for i = 0, 1, 2 are called i-cells.
(b) Elements of C0 are denoted by capital script letters and may also be

called objects.

(c) Elements of C1 are denoted by capital Roman letters and may also be

called arrows.

(d) Elements of C2 are denoted by lowercase Greek letters.

This deﬁnition is continued in 4.8.3 below.

4.8.2 Example The category Cat has a 2-category structure as follows:
the 0-cells are the small categories, the 1-cells are the functors, and the 2-
cells are the natural transformations. It will greatly aid your understanding
of 2-categories if you will read the following deﬁnitions with Cat in mind.

4.8.3 Deﬁnition of 2-category, part II A 2-category C has three cate-
gory structures on it, called the base category, the horizontal category
and the vertical category. The structure is deﬁned in terms of the last two
and the base category is then derived from them.

We continue the deﬁnition of 2-categories in 4.8.7 below.

4.8.4 Example
In Cat, the base category has small categories as objects
and functors as arrows. The vertical category has functors as objects and
natural transformations as arrows (although, of course, there are no arrows
between two functors unless those functors have the same domain and the
same codomain). The horizontal category has categories as objects and natu-
ral transformations as morphisms. In the horizontal category, the domain of
a natural transformation is the domain of its domain functor (or of its codo-
main functor, for that matter; they have to be the same) and the codomain
is the codomain of its domain (or codomain) functor.

We will amplify these remarks in 4.8.8.

4.8.5 Notation We will systematically use the words ‘base’, ‘horizontal’
and ‘vertical’ before the words ‘composition’, ‘domain’, ‘codomain’, and
‘identity’ to indicate the category structure being considered. We will also
use superscript b, h and v for these purposes, except for composition. For

142

Diagrams, naturality and sketches

example, domv α is the vertical domain of α and idhA is the horizontal iden-
tity of A . If domv α = F , codv α = G, domh α = A and codh α = B, this is
summed up by writing α : F −→ G : A −→ B.

The base and horizontal composition are denoted ∗ (it turns out that
this overloading cannot cause confusion) and the vertical composition is
denoted ◦.

4.8.6 The base category We give the deﬁnition of the base category
here, even though we have not yet stated the axioms for a 2-category, be-
cause it is useful to illustrate the axioms with certain diagrams that assume
knowledge of the base category.

The base category of a 2-category C has the 0-cells of C as objects and

the 1-cells as arrows. Its structure is determined by the following rules.
BC–1 The domain and codomain are given by domb(F ) = domh(idv(F ))

and codb(F ) = codh(idv(F )).

BC–2 The base identity idbA for a 0-cell A is idbA = domv(idhA ), which

is the same as codv(idhA ).

BC–3 The composition is denoted ∗ and is deﬁned by

G ∗ F = domv(idv G ∗ idv F )

We write F : A −→ B if domb F = A and codb F = B.

4.8.7 Deﬁnition of 2-category, part III The structure of a 2-category
C is deﬁned as follows:
TC–1 The horizontal category Ch has C0 as its set of objects and C2 as its

set of arrows.

TC–2 The vertical category Cv has C1 as its set of objects and C2 as its

set of arrows.

TC–3 A 2-cell α goes between arrows whose vertical identities have the same

horizontal domains and codomains; precisely,

domh α = domh idv(domv α) = domh idv(codv α)

and

codh α = codh idv(domv α) = codh idv(codv α)

We can illustrate this rule by the following diagram.

A

F
⇓ α

G

(cid:82)
(cid:181)

B

(4.45)

TC–4 A 2-cell that is a horizontal identity must also be a vertical identity;

precisely, for a 0-cell A ,

4.8 2-categories

143

idhA = idv(domv(idhA ))

which is necessarily also idv(codv(idhA )). Thus for all 2-cells β : H
−→ K : A −→ B,

A

idbA
⇓ idhA
idbA

(cid:82)
(cid:181)

A

H
⇓ β

K

(cid:82)
(cid:181)

B

= A

H
⇓ β

K

(cid:82)
(cid:181)

B

(4.46)

Also for all γ : idbA −→ G : A −→ A ,

idbA

idbA

A

⇓ idhA
(cid:85)
A(cid:45)
(cid:184)

⇓ γ

= A

G

idbA
⇓ γ

G

(cid:82)
(cid:181)

A

(4.47)

TC–5 For 2-cells α and β with codh α = domh β (so they are horizontally

composable)

and

idv domv(β ∗ α) = idv domv β ∗ idv domv α

idv codv(β ∗ α) = idv codv β ∗ idv codv α

The composites on the right of each equation exist by TC–3. This is
illustrated this way:

A

F
⇓ α

G

(cid:82)
(cid:181)

B

H
⇓ β

K

(cid:82)
(cid:181)

C

= A

H ∗ F
⇓ β ∗ α

K ∗ G

(cid:82)
(cid:181)

C

(4.48)

TC–6 (The interchange law) For 2-cells α, β, γ and δ for which the compos-

ites β ∗ α, δ ∗ γ, γ ◦ α and δ ◦ β are all deﬁned,

(δ ∗ γ) ◦ (β ∗ α) = (δ ◦ β) ∗ (γ ◦ α)

144

Diagrams, naturality and sketches

The interchange law applies to a situation like this:

F1

G1

B

F2

⇓ α

⇓ γ

(cid:85)
C(cid:45)
(cid:184)

G2

⇓ β

⇓ δ

(cid:85)
D(cid:45)
(cid:184)

F3

G3

(4.49)

It is necessary to show that the composites (δ ∗ γ) ◦ (β ∗ α) and (δ ◦ β) ∗ (γ ◦
α) in the interchange law are deﬁned. We verify the second and leave the ﬁrst
(which is a bit easier) as an exercise. Suppose the composites β ∗ α, δ ∗ γ,
γ ◦ α and δ ◦ β are all deﬁned. We must show that codh(γ ◦ α) = domh(δ ◦ β).
But

codh(γ ◦ α) = codh idv domv(γ ◦ α) TC–3
= codh idv domv γ
= codh γ
= domh δ
= domh idv domv δ
= domh idv domv(δ ◦ β) C–1 of 2.1.3
= domh(δ ◦ β)

C–1 of 2.1.3
TC–3
δ ∗ γ is deﬁned
TC–3

TC–3

(4.50)

as required.

Note that you can read the information about the way the domains and
codomains match directly from Diagram (4.49): the diagram makes the fact
just veriﬁed obvious. Nevertheless, the facts must be veriﬁed in the ﬁrst place
without the diagram – that is what makes it possible to draw the diagram
as shown.

We have chosen our notation so that the various entities in a 2-category look
like those in Cat. This is quite diﬀerent from most of the literature, where
0-cells are usually written with uppercase Roman letters and 1-cells with low-
ercase Roman letters. Also, in much of the literature, the composite of 2-cells
α and γ is denoted by γ ◦ α (presumably because their domains compose in the
base category to give the domain of the composite) and the vertical compos-
ite of α and β by βα. In 4.2.11, we denoted the vertical composite of natural
transformations by β ◦ α because when functors are thought of as models the
vertical composite is the composite of the corresponding homomorphisms. We
follow that usage here.

4.8.8 Example We now reexamine Cat as a 2-category in more detail,
using the notation we have developed.

In the 2-category Cat, the base category is what we have called Cat all
along. Recall that for any two small categories A and B, Func(A , B) is

4.8 2-categories

145

a category with functors from A to B as objects and natural transforma-
tions between those functors as arrows. Then the vertical category for Cat is
the disjoint union of all the categories Func(A , B); vertical composition is
the ordinary composition of natural transformations deﬁned in 4.2.11. The
horizontal category for Cat has categories as objects and natural transfor-
mations as arrows (the horizontal domain of a natural transformation α : F
−→ G : A −→ B is A , and the horizontal codomain is B), with horizontal
composition of natural transformations (4.4.4) as composition.

Now we can see in more detail how Cat satisﬁes the deﬁnition of a 2-
category. We consider TC–4 through TC–6 in detail. The other parts are
easier.

A horizontal identity in Cat is the identity natural transformation on the
functor idA for some category A . The component of this transformation at
any object A of A is simply idA, so it is immediate that the transformation
acts as the identity for vertical composition (which is deﬁned as componen-
twise composition), so that TC–4 is satisﬁed.

TC–5 follows from the deﬁnition of horizontal composition (4.4.4) of nat-
ural transformations, which requires that if α : F −→ G and β : H −→ K, then
β ∗ α : H ◦ F −→ G ◦ K. Diagram (4.30) for the identity natural transforma-
tions on the vertical domains of these functors becomes

(H ◦ F )A

(H idF )A

(cid:45)

(H ◦ F )A

(idH F )A

(cid:63)
(H ◦ F )A

(cid:45)

(H idF )A

(idH F )A
(cid:63)
(H ◦ F )A

(4.51)

This diagram commutes since all the arrows in the diagram are id(H ◦F )(A).
In particular, by Deﬁnitions 4.2.13 and 4.4.3,

(H idF )A = h(idF A) = H(idF (A)) = idH(F (A))

and by Deﬁnitions 4.2.13 and 4.4.2,

(idH F )A = (idH )(F (A)) = idH(F (A))

A similar argument works for the vertical codomain.

Finally, TC–6 is just Godement’s rule G–5, the interchange law.

4.8.9 Conceptual deﬁnition of 2-category We now give a more con-
ceptual deﬁnition of 2-category that shows that it is an example of an ‘en-
riched’ category. The primary source for enriched categories is [Kelly, 1982a].

146

Diagrams, naturality and sketches

4.8.10 Deﬁnition A 2-category C consists of the data given by CTC–1
to CTC–4 below, subject to the requirement that Diagrams (4.52) and (4.53)
commute.

CTC–1 A collection C0 of objects or 0-cells of C.
CTC–2 For every pair of 0-cells A and B, a small category C(A , B). The
objects of C(A , B) for all 0-cells A and B are called the 1-cells of
C, and the arrows of C(A , B) are called the 2-cells of C.

CTC–3 For every triple of 0-cells A , B and C , a functor

comp : C(B, C ) × C(A , B) −→ C(A , C )

called composition. (The domain of comp is the product of the
categories C(B, C ) and C(A , B) as deﬁned in 2.6.6.)

CTC–4 For every object A of C, a functor unit : T −→ C(A , A ), where T
is the terminal object in Cat, the category with one object 0 and
its identity arrow. The value unit(0) is denoted by idA .

The following diagrams must commute.

C(C , D)×C(B, C )×C(A , B)

comp × id

(cid:45)

C(B, D)×C(A , B)

id × comp

(cid:63)

C(C , D)×C(A , C )

comp

(cid:63)

C(A , D)

(cid:45)

comp

(4.52)

id × unit

(cid:169)(cid:169)(cid:169)(cid:169)(cid:188)

C(B, B)×C(A , B)

C(A , B)
(cid:72)
(cid:169)

id
(cid:63)
C(A , B)

(cid:72)(cid:72)(cid:72)

(cid:190)
comp

(cid:169)(cid:169)(cid:169)

(cid:45)
comp

unit × id

(cid:72)(cid:72)(cid:72)(cid:72)(cid:106)

C(A , B)×C(A , A )

(4.53)

4.8.11 Equivalence of the deﬁnitions To show that the deﬁnitions in 4.8.1
(as continued in 4.8.3 and 4.8.7) and 4.8.10 are equivalent is mostly straight-
forward. Given 4.8.10, the composition function comp : C(B, C ) × C(A , B)
−→ C(A , C ) produces the horizontal composite, and the vertical composite
is the composition of the category C(A , B). The fact that unit is a func-
tor means that it must take id0 to the identity 2-cell on idA in C(A , A ),
which is a vertical identity, and that 2-cell is the horizontal identity because
Diagram (4.53) commutes, so that TC–4 follows. The fact that comp is a

4.8 2-categories

147

functor immediately implies TC–5 (because functors preserve identities) and
the interchange law TC–6.

Given 4.8.1, 4.8.3 and 4.8.7, comp may be deﬁned to take two 2-cells to
their composite. The interchange law implies that comp preserves horizontal
composition, and it preserves identities by TC–5. Deﬁne unit to take id0 (the
sole arrow of T ) to idhA ; then it preserves the identity because idhA =
idv idbA , and it trivially preserves composition. Diagrams (4.52) and (4.53)
then commute because the horizontal category is a category by deﬁnition,
so that the composition is associative and has identities.

If C and D are 2-categories, a 2-functor F : C −→ D
4.8.12 2-functors
consists of three maps Fi : Ci −→ Di that are simultaneously functors from
C h −→ D h and from C v −→ D v. (It follows that they are also functors from
C b −→ D b.)

4.8.13 Example A type of category that has been considered in connec-
tion with program reﬁnement is a poset-enriched category. This is a cate-
gory C together with a partial ordering on every hom-set HomC (A, B) with
the property that for every triple A, B and C of objects, the composition
function comp : Hom(A, B) × Hom(B, C) −→ Hom(A, C) is monotone (pre-
serves order). In other words, if f ≤ f (cid:48) : A −→ B and g ≤ g(cid:48) : B −→ C, then
g ◦ f ≤ g(cid:48) ◦ f (cid:48) : A −→ C.

A poset-enriched category C can be given a 2-category structure by re-
quiring that there be exactly one 2-cell from f to g (where f, g : A −→ B) if
and only if f ≤ g, and otherwise no 2-cells from f to g. Thus for each pair
of objects A and B we construct the category C(Hom(A, B)) corresponding
to the poset Hom(A, B) as in 2.3.1. It is straightforward to verify that this
structure satisﬁes the conceptual deﬁnition of 2-category (4.8.10).

If C and D are poset-enriched, it is a suﬃcient condition for a functor

F : C −→ D to be a 2-functor that, for f, g : A −→ B, f ≤ g ⇒ F f ≤ F g.

Three categories that we have already discussed have a natural poset-

enriched structure (Exercises 2, 3 and 4).

An order-enriched category is usually deﬁned to be a poset-enriched
category in which each poset Hom(A, B) is a strict ω-CPO (see 2.4.4) in
which every pair of elements has a greatest lower bound. Applications of
this concept may be found in [Ji-Feng and Hoare, 1990], [Edalat and Smyth,
1993] and [Martin, Hoare and He, 1991].

4.8.14 Rewrite systems Let A be a ﬁnite alphabet. We will denote let-
ters in A by a, b, c . . . and strings in the Kleene closure A∗ by u, v, w . . ..
A rewrite system G consists of a ﬁnite set of productions, which are
symbols of the form y −→ z where y, z ∈ A∗.

148

Diagrams, naturality and sketches

Given a rewrite system G, a string x can be directly derived from w,
written w ⇒ x, if there are (possibly empty) strings u and v in A∗ and a
production y −→ z such that w = uyv and x = uzv. For example, if G has a
production ab −→ baa, then baba ⇒ bbaaa, abb ⇒ baab and ab ⇒ baa.

The operation

∗
⇒ (‘derives to’) is deﬁned to be the reﬂexive transitive
∗
⇒ x if and only if there is a

∗
closure of ⇒: for any string w, w
⇒ w, and w
string w(cid:48) such that w ⇒ w(cid:48) and w(cid:48) ∗

⇒ x.

A context free rewrite system is a rewrite system with the property
that in every production w −→ x, w is a string of length 1 (essentially a single
letter). A context free grammar G is a context free rewrite system with
additional structure. First, the alphabet A is the union of disjoint sets T ,
the set of terminals, and N , the set of nonterminals. The terminals are
traditionally (in academic treatments of theoretical computer science such
as [Lewis and Papadimitriou, 1981]) denoted by lowercase letters and the
nonterminals by uppercase letters. There is a distinguished nonterminal S
called the start symbol, and every production has the form V −→ w where
V is a single nonterminal and w is any string in A∗ (terminals, nonterminals,
or both). The language generated by G is the set {w ∈ T ∗ | S

∗
⇒ w}.

An example is the grammar G with one terminal a and one nonterminal

S, the start symbol, with productions

S −→ SS
S −→ aS
S −→ a

(4.54)

It turns out that context free rewrite systems are easily seen to have the
structure of a 2-category. The additional structure that makes a context free
grammar plays no role in this; we mentioned them because they are the most
familiar example of context free rewrite systems.

To see how this works, consider an example of a derivation. One can

derive aa in the grammar (4.54) by (at least) three diﬀerent routes:

S ⇒ SS ⇒ aS ⇒ aa
S ⇒ SS ⇒ Sa ⇒ aa
S ⇒ aS ⇒ aa

(4.55)

We can represent each of these by a derivation tree. This is a rooted tree
with branches ordered left to right. The root is S (traditionally put at the
top), and the children of each node are the symbols of the string derived
from that node in order. For example, in the ﬁrst derivation in (4.55), the
ﬁrst S derives to SS, so that its two children are S and S. The second S

derives to a, which is therefore its only child, and the third S also derives to
a. Thus its tree is drawn this way:

4.8 2-categories

149

S

(cid:161)

(cid:161)

(cid:64)

(cid:64)

S

a

S

a

(4.56)

The second derivation in (4.55) has the same tree as the ﬁrst, whereas the
derivation tree of the third is

S

(cid:161)

(cid:161)

(cid:64)

(cid:64)

a

S

a

(4.57)

The idea is that the ﬁrst two derivations are really ‘the same, but carried
out in a diﬀerent order’.

A more general derivation, for example

SaS ⇒SSaS ⇒aSaS ⇒aaaS ⇒aaaaS ⇒aaaaSS ⇒aaaaaS ⇒aaaaaa

(4.58)
has a derivation forest consisting of one tree for each symbol in the starting
string (SaS in this case), with that symbol as its root; each tree consists
of the part of the derivation performed on its root. The derivation forest
of (4.58) is

S

(cid:161)

(cid:161)

(cid:64)

(cid:64)

a

S

a

S

a

S

(cid:161)

(cid:161)

(cid:64)

(cid:64)

S

(cid:161)

(cid:161)

(cid:64)

(cid:64)

a

S

a

S

a

(4.59)

The derivation

SaS ⇒SSaS ⇒aSaS ⇒aSaaS ⇒aaaaS ⇒aaaaSS ⇒aaaaaS ⇒aaaaaa

150

Diagrams, naturality and sketches

has the same forest, but this derivation has a diﬀerent forest, as you can
check:

SaS ⇒aaS ⇒aaaS ⇒aaaaS ⇒aaaaaS ⇒aaaaaa

Again, if two derivations have the same derivation forest, they are essentially
the same except for the order of application of the productions.

These examples suggest the following deﬁnition.

4.8.15 Deﬁnition Let W be a context free rewrite system on the alpha-
bet A. The 2-category C(W ) associated with W is deﬁned as follows:

RS–1 C(W ) has one 0-cell.
RS–2 The 1-cells of C(W ) are the strings in A∗.
RS–3 A 2-cell α : w −→ x is the derivation forest of a derivation of x from w

using the productions of W .

RS–4 If α : w −→ x and β : w(cid:48) −→ x(cid:48) are 2-cells, then α ∗ β : ww(cid:48) −→ xx(cid:48) is
the forest corresponding to deriving ww(cid:48) to xw(cid:48) using α, then deriving
xw(cid:48) to xx(cid:48) using β. Note that deriving in the opposite order gives the
same forest.

RS–5 If α : w −→ x and γ : x −→ y are derivation forests, then α ◦ γ : w
−→ y is the forest obtained by using α, then β. Note that in this case
the order does matter. In general, the opposite order won’t give a
composition at all.

To prove that C(W ) is indeed a 2-category is straightforward but messy.

We illustrate the interchange law. Consider these four derivations:






α =

S

a

(cid:161)

(cid:161)

(cid:64)

(cid:64)

S

S











β =

S

(cid:161)

(cid:161)

(cid:64)

(cid:64)

S

S











γ =






S

a

S

a











δ =

a

S

(cid:161)

(cid:161)

(cid:64)

(cid:64)

S

a











S

a

It is clear that the derivation shown in (4.59) is both (γ ∗ δ) ◦ (β ∗ α) and
(γ ◦ α) ∗ (δ ◦ β).

4.8 2-categories

151

4.8.16 Rewrite systems in general Rewrite systems in general have
a 2-categorical structure of the same kind as context free rewrite systems.
The problem comes in deﬁning when two derivations should be regarded as
the same. A reasonable answer is that they are the same when they corre-
spond to the same pasting scheme, a 2-categorical notion which special-
izes to the concept of derivation forest in the case of context free rewrite
systems. A pasting scheme is essentially a complex of 0, 1 and 2-cells that
compose horizontally and vertically in a unique way to a particular 2-cell.
Diagram (4.49) is an example of a pasting scheme: no matter in what or-
der you compose 2-cells in that diagram, you get the same 2-cell. Pasting
schemes are characterized in [Johnson, 1989], [Power, 1990a] and [Power,
1991]. Deﬁnition 4.8.15 works for that case as well, using pasting schemes
for 2-cells instead of derivation forests.

This insight that rewrite systems and grammars are instances of 2-categories

suggests that one study rewrite systems for paths in the free category gener-
ated by a graph as a way of modeling rewriting systems in typed functional
languages as illustrated in Section 2.2.

4.8.17 Exercises

1. Suppose the composites β ∗ α, δ ∗ γ, γ ◦ α and δ ◦ β are all deﬁned. Show
that the composite (δ ∗ γ) ◦ (β ∗ α) is deﬁned.

2. Let f, g : (A, ≤) −→ (B, ≤) be monotone functions between posets. Deﬁne
f ≤ g to mean that for every x ∈ A, f (x) ≤ g(x). Show that this deﬁni-
tion makes the category of posets and monotone maps into a poset-enriched
category.

3. Show that Rel (see 2.1.14) with inclusion of relations as the ordering is
a poset-enriched category.
4. Let f, f (cid:48) : A −→ B be partial functions (see 2.1.13) with f deﬁned on A0
and f (cid:48) deﬁned on A(cid:48)
0 and that for
x ∈ A0, f (cid:48)(x) = f (x). Show that this deﬁnition makes Pfn a poset-enriched
category.

0. Deﬁne f ≤ f (cid:48) to mean that A0 ⊆ A(cid:48)

5
Products and sums

This chapter introduces products, which are constructions allowing the deﬁ-
nition of operations of arbitrary arity, and sums, which allow the speciﬁcation
of alternatives. In Set, the product is essentially the cartesian product, and
the sum is disjoint union.

Sections 5.1 through 5.3 introduce products, and Section 5.4 introduces
sums. These ideas are used to deﬁne the important concept of natural num-
bers object in Section 5.5. Section 5.6 describes a way to regard formal
languages and formal deductive systems as categories. Products and sums
then turn out to be familiar constructions. Thus in programming languages
products are records with ﬁelds, and in deductive systems product becomes
conjunction. Finally, Section 5.7 discusses distributive categories (roughly,
categories in which products distribute over sums), which are categories with
properties that one would expect deductive systems to have.

Except for the last two sections, all the sections of this chapter are used
in many places in the rest of the book. The concepts from the last two
sections are used only in examples. The last three sections of this chapter
are independent of each other.

5.1 The product of two objects in a category

5.1.1 Deﬁnition If S and T are sets, the cartesian product S × T is
the set of all ordered pairs with ﬁrst coordinate in S and second coordinate
in T ; in other words, S × T = {(s, t) | s ∈ S and t ∈ T }. The coordinates are
functions proj1 : S × T −→ S and proj2 : S × T −→ T called the coordinate
projections, or simply projections.

We give a speciﬁcation of product of two objects in an arbitrary category
which will have the cartesian product in Set as a special case. This speci-
ﬁcation is given in terms of the coordinate projections, motivated by these
two facts:

(i) you know an element of S × T by knowing what its two coordinates

are, and

153

154

Products and sums

(ii) given any element of S and any element of T , there is an element of
S × T with the given element of S as ﬁrst coordinate and the given
element of T as second coordinate.

5.1.2 The product of two objects Let A and B be two objects in a
category C . By a (not the) product of A and B, we mean an object C
together with arrows proj1 : C −→ A and proj2 : C −→ B that satisfy the
following condition.

5.1.3 For any object D and arrows q1 : D −→ A and q2 : D −→ B, there is
a unique arrow q : D −→ C:

D

q

(cid:161)

(cid:64)

(cid:64)

(cid:161)

q1
(cid:161)

(cid:161)(cid:170)
(cid:190)

A

(cid:63)
C

proj1

proj2

q2
(cid:64)
(cid:64)(cid:82)
B(cid:45)

(5.1)

such that proj1 ◦ q = q1 and proj2 ◦ q = q2.

5.1.4 Product cones The speciﬁcation above gives the product as C to-
gether with proj1 and proj2. The corresponding diagram

C

(cid:161)

proj1
(cid:161)(cid:170)

(cid:161)

(cid:64)

(cid:64)

proj2
(cid:64)(cid:82)

(5.2)

A

B

is called a product diagram or product cone, and the arrows proji are
called the projections. These projections are indexed by the set {1, 2}. The
base of the cone is the diagram D : I −→ C , where I is the discrete graph
with two nodes 1 and 2 and no arrows. This amounts to saying that the base
of the cone is the ordered pair (A, B). The diagram

(cid:161)

proj1
(cid:161)(cid:170)

(cid:161)

B

C

(cid:64)

(cid:64)

proj2
(cid:64)(cid:82)

A

(5.3)

is regarded as a diﬀerent product cone since its base is the diagram D with
D(1) = B and D(2) = A.

5.1 The product of two objects in a category

155

By a type of synecdoche, one often says that an object (such as C above)
‘is’ a product of two other objects (here A and B), leaving the projections
implicit, but the projections are nevertheless part of the structure we call
‘product’.

Products can be based on discrete graphs with other shape graphs, hav-
ing more elements (Section 5.3) or having other sets of nodes, for example
attributes of a data base such as {NAME, SALARY} (see 5.3.14). In this case
the projections would be projNAME and projSALARY.

The existence of the unique arrow q with the property given in 5.1.3 is
called the universal mapping property of the product. Any object con-
struction which is deﬁned up to a unique isomorphism (see Theorem 5.2.2)
in terms of arrows into or out of it is often said to be deﬁned by a universal
mapping property.

5.1.5 Products in Set If S and T are sets, then the cartesian product
S × T , together with the coordinate functions discussed in 5.1.1, is indeed a
product of S and T in Set. For suppose we have a set V and two functions
q1 : V −→ S and q2 : V −→ T . The function q : V −→ S × T deﬁned by

q(v) = (q1(v), q2(v))

for v ∈ V is the unique function satisfying 5.1.3. Since proji(q(v)) = qi(v) by
deﬁnition, q makes (5.1) commute with U = S × T , and it must be the only
such function since the commutativity of (5.1) determines that its value at
v must be (q1(v), q2(v)).

We discuss products in Rel and in Pfn in 5.4.7.

5.1.6 Products in categories of sets with structure In many, but
not all, categories of sets with structure, the product can be constructed by
endowing the product set with the structure in an obvious way.

5.1.7 Example If S and T are semigroups, then we can make S × T into
a semigroup by deﬁning the multiplication

(s1, t1)(s2, t2) = (s1s2, t1t2)

We verify associativity by the calculation

[(s1, t1)(s2, t2)](s3, t3) = (s1s2, t1t2)(s3, t3)
= ((s1s2)s3, (t1t2)t3)
= (s1(s2s3), t1(t2t3))
= (s1, t1)(s2s3, t2t3)
= (s1, t1)[(s2, t2)(s3, t3)]

(5.4)

156

Products and sums

Furthermore, this structure together with the coordinate projections satisﬁes
the deﬁnition of product in the category of semigroups. To see this requires
showing two things:

(a) The arrows proj1 : S × T −→ S and proj2 : S × T −→ T are homomorph-

isms of semigroups.

(b) If q1 and q2 are semigroup homomorphisms, then so is the arrow q

determined by 5.1.3.

It is necessary to show both because the deﬁnition of product in a category
C requires that the arrows occurring in Diagram (5.1) be arrows of the
category, in this case, Sem.

Requirement (a) follows from this calculation:

proj1((s1, t1)(s2, t2)) = proj1(s1s2, t1t2) = s1s2
= proj1(s1, t1) proj1(s2, t2)

and similarly for proj2.

As for requirement (b), let R be another semigroup and q1 : R −→ S and

q2 : R −→ T be homomorphisms. Then

(cid:104)q1, q2(cid:105)(r1r2) = (q1(r1r2), q2(r1r2)) = (q1(r1)q1(r2), q2(r1)q2(r2))

= (q1(r1), q2(r1))(q1(r2), q2(r2))
= (cid:104)q1, q2(cid:105)(r1)(cid:104)q1, q2(cid:105)(r2)

A construction for products similar to that for semigroups works for
most other categories of sets with structure. Also, the product of categories
as deﬁned in 2.6.6 is the product of the categories in Cat. One example of a
category of sets with structure which lacks products is the category of ﬁelds.
We discuss this in 8.2.3.

5.1.8 Products in posets We have already seen in 2.3.1 that any poset
(partially ordered set) has a corresponding category structure C(P ). Let P
be a poset and x and y two objects of C(P ) (that is, elements of P ). Let
us see what, if anything, is their product. A product must be an element z
together with a pair of arrows z −→ x and z −→ y, which is just another way
of saying that z ≤ x and z ≤ y. The deﬁnition of product also requires that
for any w ∈ P , given an arrow w −→ x and one w −→ y, there is an arrow w
−→ z.

This translates to

w ≤ x and w ≤ y implies w ≤ z

5.2 Properties of products

157

which, together with the fact that z ≤ x and z ≤ y, characterizes z as the
inﬁmum of x and y, often denoted x ∧ y. Thus the existence of products in
such a category is equivalent to the existence of inﬁmums. In particular, we
see that products generalize a well-known construction in posets. Note that
a poset that lacks inﬁmums provides an easy example of a category without
products.

5.1.9 Exercises

1. Show that the product of two categories, as in 2.6.6, is the product in the
category of categories and functors.

2. Describe the product of two monoids in the category of monoids and
monoid homomorphisms.

3. Describe the product of two posets in the category of posets and monotone
functions.

4. Let G and H be two graphs. Show that the product G × H in the
category of graphs and homomorphisms is deﬁned as follows: (G × H )0 =
G0 × H0. An arrow from (g, h) to (g(cid:48), h(cid:48)) is a pair (a, b) with a : g −→ g(cid:48)
in G and b : h −→ h(cid:48) in H . The projections are the usual ﬁrst and second
projections.

5. Show that if A is an object in a category with a terminal object 1, then

A

(cid:161)

(cid:104)(cid:105)
(cid:161)(cid:170)

(cid:161)

1

(cid:64)

(cid:64)

idA
(cid:64)(cid:82)

A

is a product diagram.

6. Give an example of a product diagram in a category in which at least one
of the projections is not an epimorphism.

5.2 Notation for and properties

of products

5.2.1 Consider sets S = {1, 2, 3}, T = {1, 2} and U = {1, 2, 3, 4, 5, 6}. De-
ﬁne proj1 : U −→ S and proj2 : U −→ T by this table:

158

Products and sums

u

1
2
3
4
5
6

proj1(u)

proj2(u)

2
1
3
2
1
3

1
1
1
2
2
2

Since the middle and right columns give every possible combination of a
number 1, 2 or 3 followed by a number 1 or 2, it follows that U , together
with proj1 and proj2, is a product of S and T . For example, if q1 : V −→ S
and q2 : V −→ T are given functions and q1(v) = 1, q2(v) = 2 for some v in
V , then the unique function q : V −→ U satisfying 5.1.3 must take v to 5.

In eﬀect, proj1 and proj2 code the ordered pairs in S × T into the set U .
As you can see, any choice of a six-element set U and any choice of proj1
and proj2 which gives a diﬀerent element of U for each ordered pair in S × T
gives a product of S and T .

This example shows that the categorical concept of product gives a more
general construction than the cartesian product construction for sets. One
cannot talk about ‘the’ product of two objects, but only of ‘a’ product.
However, the following theorem says that two products of the same two
objects are isomorphic in a strong sense.

5.2.2 Theorem Let C be a category and let A and B be two objects of C .
Suppose

C

(cid:161)

(cid:64)

(cid:64)(cid:64)(cid:82)

B

(cid:161)(cid:161)(cid:170)

A

and

D

(cid:161)

(cid:161)(cid:161)(cid:170)

(cid:64)

(cid:64)(cid:64)(cid:82)

A

B

are both product diagrams. Then there is an arrow, and only one, from C to
D such that

C

A

(cid:161)

(cid:161)(cid:170)

(cid:64)(cid:73)

(cid:64)

(cid:161)

(cid:64)

(cid:64)

(cid:64)(cid:82)

B

∼=

(5.5)

(cid:161)(cid:181)

(cid:161)

(cid:161)

(cid:63)
D

(cid:64)

commutes and this arrow is an isomorphism.

5.2 Properties of products

159

The proof we give is quite typical of the kind of reasoning common in
category theory and is worth studying, although not necessarily on ﬁrst
reading.

Proof. Let the projections be p1 : C −→ A, p2 : C −→ B, q1 : D −→ A and
q2 : D −→ B. In accordance with 5.1.3, there are unique arrows p : C −→ D
and q : D −→ C for which

p1 ◦ q = q1
p2 ◦ q = q2
q1 ◦ p = p1
q2 ◦ p = p2

(5.6)

Thus we already know there is exactly one arrow (namely p) making Dia-
gram (5.5) commute; all that is left to prove is that p is an isomorphism
(with inverse q).

The arrow q ◦ p : C −→ C satisﬁes

p1 ◦ q ◦ p = q1 ◦ p = p1 = p1 ◦ idC

p2 ◦ q ◦ p = q2 ◦ p = p2 = p2 ◦ idC

and by the uniqueness part of 5.1.3, it follows that q ◦ p = idC. If we exchange
the p’s and q’s, we similarly conclude that p ◦ q = idD and hence that p and
q are isomorphisms which are inverse to each other.

The following proposition is a converse to Theorem 5.2.2. Its proof is left

as an exercise.

5.2.3 Proposition Let

C

(cid:161)

(cid:64)

proj1
(cid:161)(cid:170)

(cid:161)

A

(cid:64)

proj2
(cid:64)(cid:82)

B

be a product diagram, and suppose that an object D is isomorphic to C by
an isomorphism i : D −→ C. Then

D

(cid:161)

(cid:64)

proj1 ◦ i
(cid:161)(cid:170)

(cid:161)

is a product diagram.

A

(cid:64)

proj2 ◦ i
(cid:64)(cid:82)

B

160

Products and sums

5.2.4 Categorists specify the product of two sets by saying that all they
care about an element of the product is what its ﬁrst coordinate is and what
its second coordinate is. Theorem 5.2.2 says that two structures satisfying
this speciﬁcation are isomorphic in a unique way.

The name ‘(s, t)’ represents the element of the product with ﬁrst coor-
dinate s and second coordinate t. In a diﬀerent realization of the product,
‘(s, t)’ represents the element of that product with ﬁrst coordinate s and
second coordinate t. The isomorphism of Theorem 5.2.2 maps the repre-
sentation in the ﬁrst realization of the product into a representation in the
second. Moreover, the universal property of product says that any name
‘(s, t)’ with s ∈ S and t ∈ T represents an element of the product: it is the
unique element x ∈ S × T with proj1(x) = s and proj2(x) = t.

In traditional approaches to foundations, the concept of ordered pair
(hence the product of two sets) is deﬁned by giving a speciﬁc model (or
what a computer scientist might call an implementation) of the speciﬁcation.
Such a deﬁnition makes the product absolutely unique instead of unique up
to an isomorphism. We recommend that the reader read the discussion of
this point in [Halmos, 1960], Section 6, who gives a beautiful discussion of
(what in present day language we call) the diﬀerence between a speciﬁcation
and an implementation.

In categories other than sets there may well be no standard implemen-
tation of products, so the speciﬁcation given is necessary. In Chapter 15, we
will discuss a category known as the category of modest sets in which any
construction requires the choice of a bijection between N and N × N. There
are many such, and there is no particular reason to choose one over another.

5.2.5 Notation for products It is customary to denote a product of
objects A and B of a category as A × B. Precisely, the name A × B applied
to an object means there is a product diagram

A × B
(cid:161)
(cid:64)

proj1
(cid:161)(cid:170)

(cid:161)

(cid:64)

proj2
(cid:64)(cid:82)

(5.7)

A

B

Using the name ‘A × B’ implies that there are speciﬁc, but unnamed, pro-
jections given for the product structure.

If A = B, one writes A × A = A2 and calls it the cartesian square of

A.

The notations A × B and A2 may be ambiguous, but because of The-
orem 5.2.2, it does not matter for categorical purposes which product the
symbol refers to.

5.2 Properties of products

161

Even in the category of sets, you do not really know which set A × B is unless
you pick a speciﬁc deﬁnition of ordered pair, and the average mathematician
does not normally need to give any thought to the deﬁnition because what really
matters is the universal property that says that an ordered pair is determined
by its values under the projections.

5.2.6 Binary operations A binary operation on a set S is a function
from S × S to S. An example is addition on the natural numbers, which is
a function + : N × N −→ N. This and other familiar binary operations are
usually written in inﬁx notation; one writes 3 + 5 = 8, for example, instead of
+(3, 5) = 8. In mathematics texts, the value of an arbitrary binary operation
m at a pair (x, y) is commonly denoted xy, without any symbol at all.

Using the concept of categorical product, we can now deﬁne the concept
of binary operation on any object S of any category provided only that there
is a product S × S: a binary operation on S is an arrow S × S −→ S.

The associative law (xy)z = x(yz) can be described using a commutative
diagram as illustrated in 4.1.11. In that section, the diagram is a diagram in
Set, but now it has a meaning in any category with products. (The meaning
of expressions such as mult ×S in arbitrary categories is given in 5.2.17
below.)

The more general concept of function of two variables can now be deﬁned
in a categorical setting: an arrow f : A × B −→ C can be thought of as the
categorical version of a function of two variables. This has the consequence
that a categorist thinks of a function such as f : R × R −→ R deﬁned by
f (x, y) = x2 + y2 as a function of one variable, but that variable is a struc-
tured variable (an ordered pair). The notation we have been using would
suggest that one write this as f ((x, y)) instead of f (x, y), but no one does.

5.2.7 Suppose we are given a product diagram (5.7). For each pair of
arrows f : C −→ A and g : C −→ B requirement 5.1.3 produces a unique
q : C −→ A × B making the following diagram commute.

C

(cid:161)

(cid:64)

(cid:64)

q

(cid:161)

(cid:161)

g
(cid:64)

f
(cid:161)

(cid:161)(cid:170)
(cid:190)

A

proj1

(cid:63)
A × B

(cid:64)
(cid:64)(cid:82)
B(cid:45)

proj2

(5.8)

In other words, it produces a function

πC : HomC (C, A) × HomC (C, B) −→ HomC (C, A × B)

Thus q = πC(f, g).

162

Products and sums

5.2.8 Proposition The function πC is a bijection.

Proof. πC is injective, since if (f, g) and (f (cid:48), g(cid:48)) are elements of

HomC (C, A) × HomC (C, B)

both of which produce the same arrow q making Diagram (5.8) commute,
then f = proj1 ◦ q = f (cid:48), and similarly g = g(cid:48).

It is also surjective, since if r : C −→ A × B is any arrow of C , then it

makes

C

(cid:161)

(cid:64)

(cid:161)

r

(cid:63)
A × B

proj1 ◦ r
(cid:161)

(cid:161)

(cid:161)(cid:170)
(cid:190)

A

proj1

(cid:64)

(cid:64)

proj2 ◦ r
(cid:64)
(cid:64)(cid:82)
B(cid:45)

proj2

(5.9)

commute, and so is the image of the pair (proj1 ◦ r, proj2 ◦ r) under πC.

5.2.9 It is customary to write (cid:104)f, g(cid:105) for πC(f, g). The arrow (cid:104)f, g(cid:105) inter-
nally represents the pair of arrows (f, g) of the category C . Proposition 5.2.8
says that the representation is good in the sense that (cid:104)f, g(cid:105) and (f, g) each
determine the other. Proposition 5.2.14 below says that the notation (cid:104)f, g(cid:105)
is compatible with composition.

We have already used the notation ‘(cid:104)f, g(cid:105)’ in the category of sets in 1.2.8.

5.2.10 In the case of two products for the same pair of objects, the iso-
morphism of 5.2.2 translates the arrow named (cid:104)f, g(cid:105) for one product into the
arrow named (cid:104)f, g(cid:105) for the other, in the following precise sense.

5.2.11 Proposition Suppose

C

(cid:161)

p1
(cid:161)(cid:170)

(cid:161)

(cid:64)

(cid:64)

p2
(cid:64)(cid:82)

and

A

B

A

D

(cid:161)

(cid:64)

q1
(cid:161)(cid:170)

(cid:161)

(cid:64)

q2
(cid:64)(cid:82)

B

are two product diagrams and φ : C −→ D is the unique isomorphism given
by Theorem 5.2.2. Let f : E −→ A and g : E −→ B be given and let u : E
−→ C, v : E −→ D be the unique arrows for which p1 ◦ u = q1 ◦ v = f and
p2 ◦ u = q2 ◦ v = g. Then φ ◦ u = v.

5.2 Properties of products

163

Note that in the statement of the theorem, both u and v could be called
‘(cid:104)f, g(cid:105)’, as described in 5.2.9. The ambiguity occurs because the pair notation
does not name which product of A and B is being used. It is rare in practice
to have two diﬀerent products of the same two objects under consideration
at the same time.

Proof. By 5.2.2, pi = qi ◦ φ, i = 1, 2. Using this, we have q1 ◦ φ ◦ u = p1 ◦
u = f and similarly q2 ◦ φ ◦ u = g. Since v is the unique arrow which makes
q1 ◦ v = u and q2 ◦ v = g, it follows that φ ◦ u = v.

This theorem provides another point of view concerning elements (s, t)
of a product S × T . As described in 2.7.19, the element s may be represented
by an arrow s : 1 −→ S, and similarly t by t : 1 −→ T . Then the arrow (cid:104)s, t(cid:105) : 1
−→ S × T represents the ordered pair (s, t) whichever realization of S × T is
chosen.

5.2.12 The switch map Our notation A × B means that A × B is the
vertex of a product cone with base the discrete diagram D with D(1) = A
and D(2) = B. Then B × A denotes the product given by the diagram

B × A
(cid:64)
(cid:161)

(cid:64)

p2
(cid:64)(cid:82)

A

p1
(cid:161)(cid:170)

(cid:161)

B

(5.10)

where we use p1 and p2 to avoid confusing them with the arrows proj1 and
proj2 of Diagram (5.7). (Of course, this is an ad hoc solution. If one had to
deal with this situation a lot it would be necessary to introduce notation
such as projA,B

.) Then this is a product diagram:

and projB,A

1

1

B × A
(cid:64)
(cid:161)

(cid:64)

p1
(cid:64)(cid:82)

p2
(cid:161)(cid:170)

(cid:161)

A

(5.11)

B

It follows from Theorem 5.2.2 that there is an isomorphism (cid:104)p2, p1(cid:105) : B × A
−→ A × B (called the switch map) that commutes with the projections. Its
inverse is (cid:104)proj2, proj1(cid:105) : A × B −→ B × A.

5.2.13 To show that the notation (cid:104)q1, q2(cid:105) is compatible with composition,
we will show that the arrows πC deﬁned in 5.2.7 are the components of a nat-
ural isomorphism. To state this claim formally, we need to make HomC (C, A)×
HomC (C, B) into a functor. This is analogous to the deﬁnition of the con-
travariant hom functor. A and B are ﬁxed and the varying object is C, so
we deﬁne the functor HomC (−, A) × HomC (−, B) as follows:

164

Products and sums

(i) [HomC (−, A) × HomC (−, B)](C) = HomC (C, A) × HomC (C, B), the

set of pairs (g, h) of arrows g : C −→ A and h : C −→ B.
(ii) For f : D −→ C, let HomC (f, A) × HomC (f, B) be the arrow

HomC (C, A) × HomC (C, B) −→ HomC (D, A) × HomC (D, B)

that takes a pair (g, h) to (g ◦ f, h ◦ f ).

Now we can state the proposition.

5.2.14 Proposition

πC : HomC (C, A) × HomC (C, B) −→ HomC (C, A × B)

constitutes a natural isomorphism

π : Hom(−, A) × Hom(−, B) −→ Hom(−, A × B)

Proof. We give a proof in detail of this proposition here, but you may want
to skip it on ﬁrst reading, or for that matter on ﬁfteenth reading. We will
not always give proofs of similar statements later (of which there are many).
Let PA,B denote the functor Hom(−, A) × Hom(−, B). The projections
p1 : A × B −→ A and p2 : A × B −→ B from the product form a pair (p1, p2) ∈
PA,B(A × B).

5.2.15 Lemma The pair (p1, p2) is a universal element for PA,B.

Proof. The pair ﬁts the requirements of Proposition 4.5.12 by deﬁnition of
product: if (q1, q2) ∈ PA,B(V ), in other words if q1 : C −→ A and q2 : C −→ B,
there is a unique arrow q : C −→ A × B such that pi ◦ q = qi for i = 1, 2.
By 5.2.13(ii), PA,B(q)(p1, p2) = (q1, q2) as required.

Note that this gives an immediate proof of Theorem 5.2.2. See 13.2.3 for

another point of view concerning (p1, p2).

Continuing the proof of Proposition 5.2.14, from Equation (4.33) it fol-
lows that the natural isomorphism α from HomC (−, A × B) to PA,B induced
by this universal element takes q : V −→ A × B to (p1 ◦ q, p2 ◦ q), which is
PA,B(q)(p1, p2). Then by deﬁnition of π we have that αC = (πC)−1, so that
π is the inverse of a natural isomorphism and so is a natural isomorphism.

It is not hard to give a direct proof of Proposition 5.2.14 using Propo-
sition 5.2.8 and the deﬁnition of natural transformation. That deﬁnition

requires that the following diagram commute for each arrow f : C −→ D:

5.2 Properties of products

165

Hom(C, A) × Hom(C, B)

(cid:45)πD

(cid:54)

Hom(C, A × B)
(cid:54)

(5.12)

Hom(D, A) × Hom(D, B)

(cid:45)

πD

Hom(D, A × B)

In this diagram, the left arrow is deﬁned as in Section 5.2.13 and the right
arrow is deﬁned as in Section 3.1.21. We leave the details as Exercise 3.

5.2.16 If f : C −→ D and q1 : D −→ A and q2 : D −→ B determine (cid:104)q1, q2(cid:105) :
D −→ A × B, then the commutativity of (5.12) says exactly that

(cid:104)q1 ◦ f, q2 ◦ f (cid:105) = (cid:104)q1, q2(cid:105) ◦ f

(5.13)

In this sense, the (cid:104)f, g(cid:105) notation is compatible with composition.

Category theorists say that the single arrow (cid:104)q1, q2(cid:105) is the internal pair of
arrows with ﬁrst coordinate q1 and second coordinate q2. The idea behind the
word ‘internal’ is that the category C is the workspace; inside that workspace
the arrow (cid:104)q1, q2(cid:105) is the pair (q1, q2).

When you think of C as a structure and look at it from the outside, you

would say that the arrow q represents the external pair of arrows (q1, q2).

5.2.17 The cartesian product of arrows The cartesian product con-
struction 1.2.9 for functions in sets can also be given a categorical deﬁnition.
Suppose that f : S −→ S(cid:48) and g : T −→ T (cid:48) are given. Then the composite
arrows f ◦ proj1 : S × T −→ S(cid:48) and g ◦ proj2 : S × T −→ T (cid:48) induce, by the
deﬁnition of product, an arrow denoted f × g : S × T −→ S(cid:48) × T (cid:48) such that

(cid:190) proj1

S

S × T

T(cid:45)proj2

f

(cid:63)
S(cid:48)

(cid:190)

proj1

f × g

(cid:63)
S(cid:48) × T (cid:48)

g

(cid:63)
T (cid:48)(cid:45)

proj2

(5.14)

commutes. Thus f × g = (cid:104)f ◦ proj1, g ◦ proj2(cid:105). It is characterized by the
properties

proj1 ◦ (f × g) = f ◦ proj1; proj2 ◦ (f × g) = g ◦ proj2

166

Products and sums

Note that we use proj1 and proj2 for the product projections among
diﬀerent objects. This is standard and rarely causes confusion since the do-
mains and codomains of the other arrows determine them. We will later call
them p1 and p2, except for emphasis.

When one of the arrows f or g is an identity arrow, say f = idS, it is

customary to write S × g for idS ×g.

An invariance theorem similar to Proposition 5.2.11 is true of cartesian

products of functions.

5.2.18 Proposition Suppose the top and bottom lines of each diagram be-
low are product cones, and that m and n are the unique arrows making the
diagrams commute. Let ψ : P −→ Q and φ : C −→ D be the unique isomorph-
isms given by Theorem 5.2.2. Then φ ◦ m = n ◦ ψ.

(cid:190) r1

S

h1

(cid:63)
A

(cid:190)

p1

P

m

(cid:63)
(cid:63)
C

T(cid:45)r2

(cid:190) s1

S

h2
(cid:63)
B(cid:45)

p2

h1

(cid:63)
A

(cid:190)

q1

Q

n

(cid:63)
(cid:63)
D

T(cid:45)s2

h2
(cid:63)
B(cid:45)

q2

Proof. For i = 1, 2,

qi ◦ φ ◦ m ◦ ψ−1 = pi ◦ m ◦ ψ−1
= hi ◦ ri ◦ ψ−1
= hi ◦ si ◦ ψ ◦ ψ−1
= hi ◦ si

(5.15)

The ﬁrst equality is the property of φ given by Theorem 5.2.2, the second by
deﬁnition of product applied to C, and the third is the deﬁning property of
ψ. It follows that φ ◦ m ◦ ψ−1 is the unique arrow determined by h1 ◦ s1 : Q
−→ A and h2 ◦ s2 : Q −→ B and the fact that D is a product. But n is that
arrow, so that φ ◦ m ◦ ψ−1 = n, whence the theorem.

5.2.19 Products and composition Let C be a category with products,
and suppose fi : Ai −→ Bi and gi : Bi −→ Ci for i = 1, 2, so that g1 ◦ f1 and
g2 ◦ f2 are deﬁned. Then

(g1 ◦ f1) × (g2 ◦ f2) = (g1 × g2) ◦ (f1 × f2) : A1 × A2 −→ C1 × C2

(5.16)

This follows from the fact that (g1 ◦ f1) × (g2 ◦ f2) is the unique arrow

such that

proj1 ◦ ((g1 ◦ f1) × (g2 ◦ f2)) = (g1 ◦ f1) ◦ proj1

5.2 Properties of products

167

and

proj2 ◦ ((g1 ◦ f1) × (g2 ◦ f2)) = (g2 ◦ f2) ◦ proj2

Because Diagram (5.14) commutes, we have

proj1 ◦ (g1 × g2) ◦ (f1 × f2) = g1 ◦ proj1 ◦ (f1 × f2)

= g1 ◦ f1 ◦ proj1 : A1 × A2 −→ C1

and similarly

proj2 ◦ (g1 × g2) ◦ (f1 × f2) = g2 ◦ f2 ◦ proj2 : A1 × A2 −→ C2

so the result follows from the uniqueness of (g1 ◦ f1) × (g2 ◦ f2).

This fact allows us to see that the product of two objects is the value of
a functor. Deﬁne − × − : C × C −→ C as follows: choose, for each pair A
and B of C , a product object A × B, and let (− × −)(A, B) = A × B and
(− × −)(f, g) = f × g. Equation (5.16) shows that this mapping preserves
composition and identities.

Another useful equation is the following, where we assume f : A −→ C,

g : B −→ D, u : X −→ A and v : X −→ B.

(f × g) ◦ (cid:104)u, v(cid:105) = (cid:104)f ◦ u, g ◦ v(cid:105)

(5.17)

The proof is left as an exercise.

5.2.20 Proposition Let C and D be any categories. If D has products,
then the functor category Func(C , D) also has products.

Proof. The product is constructed by constructing the product at each value
F (C) and G(C). Precisely, given two functors F, G : C −→ D, the product in
Func(C , D) of F and G is the functor F ×G deﬁned as follows. For an object
C of C , (F × G)(C) = F (C) × G(C), the product of the sets F (C) and G(C)
in D. For an arrow f : C −→ D, (F × G)(f ) = F (f ) × G(f ), the product of
the arrows as deﬁned in 5.2.17. The projection π1 : F × G −→ F is the natural
transformation whose component at C is π1C = pi : F (C) × G(C) −→ F (C),
the product projection in D. For any f : C −→ D in C , the diagrams

F C×GC

F C(cid:45)p1

F C×GC

GC(cid:45)p2

F (f )×G(f )

F (f )

F (f )×G(f )

G(f )

(cid:63)

F D × GD

(cid:63)
F D(cid:45)
p1

(cid:63)

F D×GD

(cid:63)
GD(cid:45)
p2

(5.18)

168

Products and sums

commute by deﬁnition of F (f ) × G(f ) (5.2.17), so that π1 and π2 are natural
transformations as required.

Given natural transformations α : H −→ F and β : H −→ G, we must
deﬁne (cid:104)α, β(cid:105) : H −→ F × G. For an object C, the component (cid:104)α, β(cid:105)C =
(cid:104)αC, βC(cid:105) : H(C) −→ F (C)×β(C). To see that (cid:104)α, β(cid:105) is a natural transforma-
tion, we must show that for any arrow f : C −→ D, this diagram commutes:

H(C)

(cid:104)α, β(cid:105)C

(cid:45)

F (C)×G(C)

H(f )

F (f )×G(f )

(5.19)

(cid:63)
H(D)

(cid:45)

(cid:104)α, β(cid:105)D

(cid:63)
F (D)×G(D)

This follows from the following calculation:

(F (f ) × G(f )) ◦ (cid:104)α, β(cid:105)C = (F (f ) × G(f )) ◦ (cid:104)αC, βC(cid:105)

= (cid:104)F (f ) ◦ αC, G(f ) ◦ βC(cid:105)
= (cid:104)αD ◦ H(f ), βD ◦ H(f )(cid:105)
= (cid:104)αD, βD(cid:105) ◦ H(f )
= (cid:104)α, β(cid:105)D ◦ H(f )

in which the ﬁrst and last equalities are by deﬁnition of (cid:104)α, β(cid:105), the second is
by Equation (5.17), the third because α and β are natural transformations,
and the fourth by Equation (5.13).

Categorists say that this construction shows that Func(C , D ) has ‘pointwise
products’. This is the common terminology, but it might be better to say it has
‘objectwise products’.

5.2.21 Corollary The category of models of a linear sketch has products
constructed pointwise.

This follows from the fact that the category of models of a linear sketch

S is equivalent to the functor category Func(Th(S ), Set) (see 4.6.11).

5.2.22 Exercises

1. Give explicitly the isomorphism claimed by Theorem 5.2.2 between S × T
and the set {1, 2, 3, 4, 5, 6} expressed as the product of {1, 2, 3} and {1, 2}
using the projections in 5.2.1.

2. Given a two-element set A and a three-element set B, in how many
ways can the set {1, 2, 3, 4, 5, 6} be made into a product A × B? (This refers
to 5.2.1.)

5.3 Finite products

169

3. Prove that Diagram (5.12) commutes.

4. Prove Proposition 5.2.3.

5. Let f : A −→ C, g : B −→ D, u : X −→ A and v : X −→ B. Show that
(f × g) ◦ (cid:104)u, v(cid:105) = (cid:104)f ◦ u, g ◦ v(cid:105).

5.3 Finite products

Products of two objects, as discussed in the preceding sections, are called
binary products. We can deﬁne products of more than two objects by an
obvious modiﬁcation of the deﬁnition.

For example, if A, B and C are three objects of a category, a product of

them is an object A × B × C together with three arrows:

A × B × C

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

A

(cid:64)

(cid:161)

p2

(cid:63)
B

for which, given any other diagram

(cid:161)

D

q2

(cid:64)

(cid:63)
B

(cid:161)

q1
(cid:161)

(cid:161)(cid:170)

A

(cid:64)

p3
(cid:64)

(cid:64)(cid:82)

(cid:64)

q3
(cid:64)

(cid:64)(cid:82)

(5.20)

C

C

there exists a unique arrow q = (cid:104)q1, q2, q3(cid:105) : D −→ A × B × C such that pi ◦
q = qi, i = 1, 2, 3. A diagram of the form (5.20) is called a ternary product
diagram (or ternary product cone). The general deﬁnition of product follows
the same pattern.

5.3.1 Deﬁnition A product of a list A1, A2, . . . , An of objects (not nec-
essarily distinct) of a category is an object V together with arrows pi : A
−→ Ai, for i = 1, . . . , n, with the property that given any object B and arrows
fi : B −→ Ai, i = 1, . . . , n, there is a unique arrow (cid:104)f1, f2, . . . , fn(cid:105) : B −→ A
for which pi ◦ (cid:104)f1, f2, . . . , fn(cid:105) = fi, i = 1, . . . , n.

A product of such a list A1, A2, . . . , An is called an n-ary product when
it is necessary to specify the number of factors. Such a product may be
i=1 Ai.
denoted A1 × A2 × · · · × An or

(cid:81)n

The following uniqueness theorem for general ﬁnite products can be

proved in the same way as Theorem 5.2.2.

170

Products and sums

5.3.2 Theorem Suppose A1, A2, . . . , An are objects of a category C and
that A, with projections pi : A −→ Ai, and B, with projections qi : B −→ Ai,
are products of these objects. Then there is a unique arrow φ : A −→ B for
which qi ◦ φ = pi for i = 1, . . . , n. Moreover, φ is an isomorphism.

Propositions 5.2.3, 5.2.11 and 5.2.18 also generalize in the obvious way

to n-ary products.

5.3.3 Binary products give ternary products An important conse-
quence of the deﬁnition of ternary product is that in any category with
binary products, and any objects A, B and C, either of (A × B) × C and
A × (B × C) can be taken as ternary products A × B × C with appropriate
choice of projections.

We prove this for (A × B) × C. Writing pi, i = 1, 2, for the projections
which make A × B a product of A and B and qi, i = 1, 2 for the projections
which make (A × B) × C a product of A × B and C, we claim that

(A × B) × C
q1 (cid:161)
(cid:161)(cid:161)(cid:170)
A × B

(cid:64)

(cid:64)

p1 (cid:161)
(cid:161)(cid:161)(cid:170)

p2(cid:64)
(cid:64)(cid:64)(cid:82)

A

B

(cid:64)

q2
(cid:64)

(cid:64)

(cid:64)(cid:82)

C

is a product diagram with vertex (A × B) × C and projections p1 ◦ q1 :
(A × B) × C −→ A, p2 ◦ q1 : (A × B) × C −→ B, and q2 : (A × B) × C −→ C.
Suppose that f : D −→ A, g : D −→ B, and h : D −→ C are given. We

must construct an arrow u : D −→ (A × B) × C with the property that

(a) p1 ◦ q1 ◦ u = f ,
(b) p2 ◦ q1 ◦ u = g, and
(c) q2 ◦ u = h.

Recall that (cid:104)f, g(cid:105) is the unique arrow making

D

(cid:161)

(cid:64)

(cid:64)

(cid:161)

f
(cid:161)

(cid:161)(cid:170)
(cid:190)

p1

A

(cid:104)f, g(cid:105)

(cid:63)
A × B

g
(cid:64)
(cid:64)(cid:82)
B(cid:45)

p2

(5.21)

commute. This induces a unique arrow u = (cid:104)(cid:104)f, g(cid:105), h(cid:105) making

5.3 Finite products

171

D

(cid:161)

(cid:64)

(cid:161)

(cid:64)

(cid:64)

u

(cid:63)

(A × B) × C

(cid:161)

(cid:104)f, g(cid:105)
(cid:161)

(cid:161)(cid:170)
A × B

(cid:161)
(cid:190)
q1

(5.22)

h
(cid:64)

(cid:64)
(cid:64)(cid:82)
C(cid:45)

q2

commute.

The fact that (a) through (c) hold can be read directly oﬀ these diagrams.

For example, for (a), p1 ◦ q1 ◦ u = p1 ◦ (cid:104)f, g(cid:105) = f .

Finally, if u(cid:48) were another arrow making (a) through (c) hold, then we
would have p1 ◦ q1 ◦ u(cid:48) = f and p2 ◦ q1 ◦ u(cid:48) = g, so by uniqueness of v as
deﬁned by (5.21), v = q1 ◦ u(cid:48). Since q2 ◦ u(cid:48) must be h, the uniqueness of u
in (5.22) means that u(cid:48) = u.

A generalization of this is stated in Proposition 5.3.10 below.

5.3.4 It follows from the discussion in 5.3.3 that the two objects (A × B) ×
C and A × (B × C) are pairwise canonically isomorphic (to each other and
to any other realization of the ternary product) in a way that preserves the
ternary product structure.

In elementary mathematics texts the point is often made that ‘cartesian prod-
uct is not associative’. When you saw this you may have thought in your heart
of hearts that (A × B) × C and A × (B × C) are nevertheless really the same.
Well, now you know that they are really the same in a very strong sense: they
satisfy the same speciﬁcation and so carry exactly the same information. The
only diﬀerence is in implementation.

5.3.5 If all the factors in an n-ary product are the same object A, the n-
ary product A × A × · · · × A is denoted An. This suggests the possibility of
deﬁning the nullary product A0 and the unary product A1.

5.3.6 For nullary products, the deﬁnition is: given no objects of the cate-
gory C , there should be an object we will temporarily call T , with no arrows
from it, such that for any other object B and no arrows from B, there is a
unique arrow from B to T subject to no commutativity condition.

When the language is sorted out, we see that a nullary product in C is
simply an object T with the property that every other object of the category
has exactly one arrow to T . That is, T must be a terminal object of the
category, normally denoted 1. Thus, for any object A of the category, we
take A0 = 1. (Compare 4.1.6.)

172

Products and sums

5.3.7 A unary product A1 of a single object A should have an arrow p : A1
−→ A with the property that given any object B and arrow q : B −→ A there
is a unique arrow (cid:104)q(cid:105) : B −→ A1 for which

A1(cid:45)(cid:104)q(cid:105)

B

(cid:64)
q
(cid:64)

(cid:64)

(cid:64)(cid:82)

p

(cid:63)
A

(5.23)

commutes. The identity id : A −→ A satisﬁes this speciﬁcation for p; given
the arrow q : B −→ A, we let (cid:104)q(cid:105) = q : B −→ A. The fact that id ◦ (cid:104)q(cid:105) = q is
evident, as is the uniqueness of (cid:104)q(cid:105). It follows that A1 can always be taken
to be A itself, with the identity arrow as the coordinate arrow.

It is straightforward to show that in general an object B is a unary
product of A with coordinate p : B −→ A if and only if p is an isomorphism
(Exercise 1.b).

There is therefore a conceptual distinction between A1 and A. In the
category of sets, An is often taken to be the set of strings of elements of A
of length exactly n. As you may know, in some computer languages, a string
of characters of length one is not the same as a single character, mirroring
the conceptual distinction made in category theory.

5.3.8 Deﬁnition A category has binary products if the product of any
two objects exists. It has canonical binary products if a speciﬁc product
diagram is given for each pair of objects. Thus a category with canonical
binary products is a category with extra structure given for it. Precisely,
a canonical binary products structure on a category C is a function from
C0 × C0 to the collection of product diagrams in C which takes a pair (A, B)
to a diagram of the form (5.2).

The fact that A and idA can be taken as a product diagram for any object
A of any category means that every category can be given a canonical unary
product structure. This is why the distinction between A and A1 can be and
often is ignored.

5.3.9 Deﬁnition A category has ﬁnite products or is a cartesian cat-
egory if the product of any ﬁnite number of objects exists. This includes
nullary products – in particular, a category with ﬁnite products has a ter-
minal object. The category has canonical ﬁnite products if every ﬁnite
list of objects has a speciﬁc given product.

The following proposition is proved using constructions generalizing those

of 5.3.3. (See Exercises 1.c and 6.)

5.3.10 Proposition If a category has a terminal object and binary prod-
ucts, then it has ﬁnite products.

5.3 Finite products

173

5.3.11 Set, Grf and Cat all have ﬁnite products. In fact, a choice of deﬁ-
nition for ordered pairs in Set provides canonical products not only for Set
but also for Grf and Cat, since products in those categories are built using
cartesian products of sets.

5.3.12 Products and initial objects The notation A0, A1, A2 and so
on that we have introduced, plus isomorphisms such as A × B ∼= B × A
(5.2.12) and (A × B) × C ∼= A × (B × C) (5.3.4), suggest that other algebraic
laws may hold for products. One candidate is A × 0 ∼= 0, where 0 denotes
the initial object. This is false in general. For example, in Mon the initial
object is the one-element monoid (which is also the terminal object), and its
product with any monoid M is M by Exercise 5 of Section 5.1.

It is important in such areas as programming language semantics and
categorical logic that a category have the property A × 0 ∼= 0. It is equivalent
to another property, as the following proposition states. We include its proof
here because it uses several ideas we have introduced.

We denote an initial object by 0 and the unique map to an object A is
denoted ! : 0 −→ A. As before, a terminal object is denoted 1 and the unique
map from an object A is denoted (cid:104)(cid:105) : A −→ 1.

5.3.13 Proposition Let C be a category with products and an initial object.
Then the following two statements are equivalent.

(i) For every object A, if there is an arrow u : A −→ 0, then A is iso-

morphic to 0.

(ii) For every object A, 0 × A is isomorphic to 0.

In any category, if the initial object has this property, it is called a strict

initial object.
Proof. If (i) is true, the map p1 : 0 × A −→ 0 serves to force 0 × A ∼= 0. If (ii)
holds, the following must be a product diagram.

0

(cid:161)

id0
(cid:161)(cid:170)

(cid:161)

(cid:64)

!
(cid:64)
(cid:64)(cid:82)

0

A

(Since 0 × A is isomorphic to 0, there has to be such a product diagram with
0 as vertex, and there is only one possible arrow for each projection.) That

174

Products and sums

means this diagram must commute:

A

(cid:161)

(cid:64)

u
(cid:161)
(cid:161)(cid:170)
(cid:190)

id0

0

u
(cid:63)
0

idA
(cid:64)
(cid:64)(cid:82)
A(cid:45)

!

(5.24)

The commutativity of the right triangle says that u is a split monic. Since
any arrow to an initial object is epimorphic, the result follows from Propo-
sition 2.9.10.

5.3.14 Record types To allow operations depending on several variables
in a functional programming language L (as discussed in 2.2.1), it is reason-
able to assume that for any types A and B the language has a record type
P and two ﬁeld selectors P ◦ A : P −→ A and P ◦ B : P −→ B. If we insist
that the data in P be determined completely by those two ﬁelds, it follows
that for any pair of operations f : X −→ A and g : X −→ B there ought to be
a unique operation (cid:104)f, g(cid:105) : X −→ P with the property that P ◦ A ◦ (cid:104)f, g(cid:105) = f
and P ◦ B ◦ (cid:104)f, g(cid:105) = g. This would make P the product of A and B with the
selectors as product projections.

For example, a record type PERSON with ﬁelds NAME and AGE could be
represented as a product cone whose base diagram is deﬁned on the discrete
graph with two nodes NAME and AGE. If HUMAN is a variable of type PERSON,
then the ﬁeld selector HUMAN.AGE implements the coordinate projection in-
dexed by AGE. This example is closer to the spirit of category theory than
the cone in Diagram (5.2); there, the index graph has nodes 1 and 2, which
suggests an ordering of the nodes (and the projections) which is in fact
spurious.

Thus to say that one can always construct record types in a functional
programming language L is to say that the corresponding category C(L) has
ﬁnite products. (See Poign´e, [1986].)

5.3.15 Functors that preserve products Let F : A −→ B be a functor
between categories. Suppose that

A

(cid:64)

(cid:64)

p2
(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

A1

(5.25)

A2

is a (binary) product diagram in A . We say that F preserves the product
if

F A

5.3 Finite products

175

(cid:161)

(cid:161)

(cid:64)

F p1
(cid:161)
(cid:161)(cid:170)

F A1

(cid:64)

F p2
(cid:64)
(cid:64)(cid:82)

F A2

is a product diagram in B. It is important to note that F must preserve the
diagram, not merely the object A. It is possible for F to take A to an object
which is isomorphic to a product, but do the wrong thing on projections
(Exercise 4).

F preserves canonical products if A and B have canonical products

and F preserves the canonical product diagrams.

Similar deﬁnitions can be made about a product diagram of any family
of objects. A functor is said to preserve ﬁnite products, respectively all
products if it preserves every ﬁnite product diagram, respectively all prod-
uct diagrams. Preserving canonical product diagrams is deﬁned analogously
(but note Exercise 5.b).

We have a proposition related to Proposition 5.3.10.

5.3.16 Proposition If a functor preserves terminal objects and binary
products, it preserves all ﬁnite products.

Two important examples of this is given by Propositions 5.3.17 and 5.3.18

below.

5.3.17 Proposition Any covariant hom functor preserves products.

Proof. A covariant hom functor preserves terminal objects by Exercise 11 of
Section 3.3. Now suppose

A × B

p1 (cid:161)
(cid:161)(cid:170)

p2(cid:64)
(cid:64)(cid:82)

A

B

is a product diagram. We must show that for any object C,

Hom(C, A × B)

(cid:161)

(cid:64)

(cid:161)

Hom(C, p1)
(cid:161)(cid:161)(cid:170)

Hom(C, A)

(cid:64)

Hom(C, p2)
(cid:64)(cid:64)(cid:82)
Hom(C, B)

(5.26)

(5.27)

176

Products and sums

is a product diagram in Set. In 5.2.7, we deﬁned the function

πC : Hom(C, A) × Hom(C, B) −→ Hom(C, A × B)

which is a bijection that takes (f, g) to (cid:104)f, g(cid:105). Let q1 : Hom(C, A)×Hom(C, B)
−→ Hom(C, A) be the ﬁrst coordinate function (f, g) (cid:55)→ f in Set, and simi-
larly for q2. Then

Hom(C, p1)(cid:104)f, g(cid:105) = p1 ◦ (cid:104)f, g(cid:105) = f = q1(f, g)

and similarly Hom(C, p2)(cid:104)f, g(cid:105) = q2(f, g), so pi ◦ πC = qi for i = 1, 2. Hence
Diagram (5.27) is a product diagram in Set by Proposition 5.2.3.

If F is a functor that preserves products, then any functor isomorphic to
it preserves products (Exercise 7), so that it follows from Proposition 5.3.17
that any representable functor preserves products.

5.3.18 Proposition The second Yoneda embedding

J : C −→ Func(C op, Set)

(see 4.5.5) preserves products.

Proof. By deﬁnition, J(C) = Hom(−, C) for an object C of C , and if f : C
−→ D, J(f ) = Hom(−, f ) : Hom(−, C) −→ Hom(−, D). For each X in C ,

Hom(X, A)× Hom(X, B)

p1
(cid:161)(cid:170)

(cid:161)

(cid:161)

(cid:64)

(cid:64)

p2
(cid:64)(cid:82)

Hom(X, A)

Hom(X, B)

(where p1 and p2 are the ordinary projections in Set) is a product cone in
Set. Let π1 : Hom(−, A)× Hom(−, B) −→ Hom(−, A) be the natural trans-
formation whose component at X is p1, and similarly deﬁne π2. Then by the
proof of Proposition 5.2.20,

Hom(−, A)× Hom(−, B)

π1
(cid:161)(cid:170)

(cid:161)

(cid:161)

(cid:64)

(cid:64)

π2
(cid:64)(cid:82)

Hom(−, A)

Hom(−, B)

is a product cone in Func(C op, Set). It is easy to show that the diagram

Hom(−, A)× Hom(−, B)

(cid:45)π

Hom(−, A×B)

(cid:161)
Hom(−, p1)

(cid:161)

(cid:64)
π1

(cid:64)

(cid:64)

(cid:161)

(cid:64)(cid:64)(cid:82)

(cid:161)(cid:161)(cid:170)

Hom(−, A)

commutes, where π1 is an instance of the natural transformation deﬁned in
Proposition 5.2.14. A similar diagram for π2 also commutes. It now follows
from Proposition 5.2.3 that

5.3 Finite products

177

Hom(−, A×B)

(cid:161)

Hom(−, p1)
(cid:161)(cid:170)

(cid:161)

Hom(−, A)

(cid:64)

(cid:64)

Hom(−, p2)
(cid:64)(cid:82)

Hom(−, B)

is a product diagram in Func(C op, Set), which is what is required to show
that J preserves binary products. It is easy to show that it preserves terminal
objects.

5.3.19 Inﬁnite products There is no diﬃculty in extending the deﬁni-
tion of products to allow inﬁnitely many objects. Suppose I is an arbitrary set
and {Ai}, i ∈ I is an indexed set of objects of the category C . (See 2.6.11.)
A product of the indexed set is an object P of A together with an indexed
set of arrows pi : P −→ Ai, i ∈ I, such that given any object A of A together
with arrows qi : A −→ Ai, for i ∈ I, there is a unique arrow q = (cid:104)qi(cid:105) : A −→ P
such that pi ◦ q = qi, for all i ∈ I. The product P is denoted by
i∈I Ai or
simply

(cid:81)

(cid:81)

Ai.

5.3.20 Exercises

1. a. Show that assuming B × C and A × (B × C) (along with the required
projections) exist, then the latter with appropriately deﬁned projections is
a ternary product A × B × C.

b. Show that p : B −→ A is a unary product diagram if and only if p is

an isomorphism.

c. Show that a category which has binary products and a terminal object

has ﬁnite products.

2. Let C be a category with the following properties.

(i) For any two objects A and B there is an object A × B and arrows

p1 : A × B −→ A and p2 : A × B −→ B.

(ii) For any two arrows q1 : X −→ A and q2 : X −→ B there is an arrow

(cid:104)q1, q2(cid:105) : X −→ A × B.

(iii) For any arrows q1 : X −→ A and q2 : X −→ B, p1 ◦ (cid:104)q1, q2(cid:105) = q1 and

p2 ◦ (cid:104)q1, q2(cid:105) = q2.

(iv) For any arrow h : Y −→ A × B, (cid:104)p1 ◦ h, p2 ◦ h(cid:105) = h.

Prove that C has binary products. (This exercise shows that the property
of having binary products can be expressed using rewrite rules.)

178

Products and sums

3. Show that the underlying functor U : Cat −→ Grf deﬁned in 3.1.10 pre-
serves products.
4.† Give an example of categories C and D with products and a functor
F : C −→ D which does not preserve products, but for which nevertheless
F (A × B) ∼= F (A) × F (B) for all objects A and B of C . (Hint: Consider
the category whose objects are countably inﬁnite sets and arrows are all
functions between them.)

5. a. Show that a functor which preserves terminal objects and binary prod-
ucts preserves ﬁnite products.

b. Give an example of categories C and D with canonical ﬁnite products
and a functor F : C −→ D which preserves canonical binary products which
does not preserve canonical ﬁnite products.

6. Let N be the set of nonnegative integers with the usual ordering. Show
that the category determined by (N, ≤) has all binary products but no ter-
minal object.

7. Let F, G : C −→ D be naturally isomorphic functors and suppose

P

(cid:161)

p2
(cid:161)(cid:170)

(cid:161)

A

(cid:64)

(cid:64)

p1
(cid:64)(cid:82)

B

is a product diagram in C . Show that if either of the diagrams

F (P )

(cid:161)

(cid:64)

F (p1)
(cid:161)(cid:170)

(cid:161)

F (A)

(cid:64)

F (p2)
(cid:64)(cid:82)

F (B)

G(P )

(cid:161)

(cid:64)

G(q1)
(cid:161)(cid:170)

(cid:161)

G(A)

(cid:64)

G(q2)
(cid:64)(cid:82)

G(B)

is a product diagram in D then so is the other. (Hence if a functor preserves
products then so does any functor isomorphic to it.)

5.4 Sums

A sum in a category is a product in the dual category. This deﬁnition spells
that out:

5.4.1 Deﬁnition The sum, also called the coproduct, A + B of two
objects in a category consists of an object called A + B together with arrows

i1 : A −→ A + B and i2 : B −→ A + B such that given any arrows f : A −→ C
and g : B −→ C, there is a unique arrow (cid:104)f |g(cid:105) : A + B −→ C for which

5.4 Sums

179

A

(cid:64)

(cid:190) g

C(cid:45)f
(cid:54)

B

(cid:161)

(cid:64)
i1

(cid:64)

(cid:161)
i2

(cid:161)

(cid:104)f |g(cid:105)

(cid:161)

(cid:64)

(cid:161)(cid:170)
(cid:64)(cid:82)
A + B

commutes.

The arrows i1 and i2 are called the canonical injections or the inclu-
sions even in categories other than Set. These arrows need not be mono-
morphisms (Exercise 5).

(cid:96)n

i=1 An or

5.4.2 More generally, one can deﬁne the sum of any ﬁnite or inﬁnite in-
dexed set of objects in a category. The sum of a family A1, . . . , An is denoted
(cid:80)n
i=1 An (the latter symbol is the one typically used by those who
call the sum the ‘coproduct’). Theorems such as Theorem 5.2.2 and Propo-
sitions 5.2.3, 5.2.11 and 5.3.2 are stateable in the opposite category and give
uniqueness theorems for sums (this depends on the fact that isomorphisms
are isomorphisms in the opposite category). The functor represented by the
sum of A and B is Hom(A, −) × Hom(B, −) and the universal element is the
pair of canonical injections. (Compare Proposition 5.2.14 and the discussion
which follows.)

5.4.3 Deﬁnition A binary discrete cocone in a category C is a dia-
gram of the form

A

B

(cid:64)

(cid:64)(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:161)(cid:170)

C

It is a sum cocone if the two arrows shown make C a sum of A and B.

5.4.4 The notions of a category having sums or of having canonical sums,
and that of a functor preserving sums, are deﬁned in the same way as for
products. The notion corresponding to f ×g for two arrows f and g is denoted
f + g (Exercise 1).

5.4.5 Sums in Set In the category of sets, one can ﬁnd a sum of two
sets in the following way. If S and T are sets, ﬁrst consider the case that S
and T are disjoint. In that case the set S ∪ T , together with the inclusion

180

Products and sums

functions S −→ S ∪ T ←− T is a sum cocone. Given f : S −→ C and g : T
−→ C, then (cid:104)f |g(cid:105)(s) = f (s) for s ∈ S and (cid:104)f |g(cid:105)(t) = g(t) for t ∈ T . In this
case, the graph of (cid:104)f |g(cid:105) is the union of the graphs of f and g.

In the general case, all we have to do is ﬁnd sets S(cid:48) and T (cid:48) isomorphic to
S and T , respectively, that are disjoint. The union of those two sets is a sum
of S(cid:48) and T (cid:48) which are the same, as far as mapping properties, as S and T .
The usual way this is done is as follows: let

S(cid:48) = S0 = {(s, 0) | s ∈ S} and T (cid:48) = T1 = {(t, 1) | t ∈ T }

These sets are disjoint since the ﬁrst is a set of ordered pairs each of whose
second entries is a 0, while the second is a set of ordered pairs each of whose
second entries is a 1. The arrow i1 : S −→ S(cid:48) ∪ T (cid:48) takes s to (s, 0), and i2
takes t to (t, 1). If f : S −→ C and g : T −→ C, then (cid:104)f |g(cid:105)(s, 0) = f (s) and
(cid:104)f |g(cid:105)(t, 1) = g(t).

Note that it will not do to write S0 = S × {0} and T1 = T × {1} since our
speciﬁcation of products does not force us to use ordered pairs and, in fact, S
is itself a possible product of S with either {0} or {1}.

Our notation S + T for the disjoint union of two sets in Set conﬂicts with
a common usage in which S and T are sets of numbers and S + T denotes
the set of all their sums. For this reason, many use the notation S (cid:113) T for
what we call S + T . We will use the notation S + T here but will remind you
by referring to it as the disjoint union.

5.4.6 Sums and products in posets The least upper bound or su-
premum of two elements x and y in a poset is an element z with the property
that x ≤ z, y ≤ z (z is thus an upper bound) and if for some element w,
x ≤ w and y ≤ w, then necessarily z ≤ w (z is the – necessarily unique – least
upper bound). In the category corresponding to the poset, the supremum of
two elements is their categorical sum. We have already seen the dual idea of
greatest lower bound or inﬁmum in 5.1.8.

A poset whose corresponding category has all ﬁnite sums is called a sup
semilattice or an upper semilattice. The sup of s and t is generally
denoted s ∨ t and the minimum element (initial object) is denoted 0. In
this situation, the minimum element is often called ‘bottom’. A poset with
all ﬁnite products is similarly an inf semilattice or lower semilattice.
A homomorphism of sup semilattices is a function such that f (s ∨ t) =
f (s) ∨ f (t). Such a function is monotone because if s ≤ t then t = s ∨ t.

A poset with both ﬁnite sups and ﬁnite infs is a lattice. Some authors
assume only binary sups and infs so that a lattice need not have a maximum
or minimum element. A good source for the theory of lattices is [Davey and
Priestley, 1990].

5.4 Sums

181

5.4.7 Sums and products in Rel and Pfn Let S and T be two sets.
Their sum in Rel, the category of sets and relations (2.1.14) and in Pfn,
the category of sets and partial functions (2.1.13) is the same as in Set: the
disjoint union S + T . For Pfn, the canonical injections are the same as for
Set, and for Rel they are the graphs of the canonical injections for Set.

We will verify this for Rel (primarily to show the subtleties involved)
and leave the claim for Pfn as an exercise. Set i1 = {(s, (s, 0)) | s ∈ S} and
i2 = {(t, (t, 1)) | t ∈ T }. For relations α : S −→ X and β : T −→ X, deﬁne

(cid:104)α|β(cid:105) = {((s, 0), x) | for all (s, x) ∈ α} ∪ {((t, 1), x) | for all (t, x) ∈ β}

Then

(cid:104)α|β(cid:105) ◦ i1 = {(r, x) | ∃z such that (r, z) ∈ i1 and (z, x) ∈ (cid:104)α|β(cid:105)}

= {(r, x) | r ∈ S and (r, (r, 0)) ∈ i1 and ((r, 0), x) ∈ (cid:104)α|β(cid:105)}
= {(r, x) | r ∈ S and ((r, 0), x) ∈ (cid:104)α|β(cid:105)}
= {(r, x) | r ∈ S and (r, x) ∈ α}
= α

and similarly for i2 and β.

Now suppose we omitted a particular element ((s0, 0), x0) from (cid:104)α|β(cid:105).
Since i1 has the functional property (see 1.2.3), the only z for which (s0, z) ∈
i1 is (s0, 0), but then ((s0, 0), x0) /∈ (cid:104)α|β(cid:105). On the other hand, if we insert an
extra element (r, x) into (cid:104)α|β(cid:105), suppose without loss of generality that r =
(s0, 0) for s ∈ S and (s, x) /∈ α. Then (s, (s0, 0)) ∈ i1 and ((s0, 0), x) ∈ (cid:104)α|β(cid:105)
but (s, x) /∈ α. So (cid:104)α, β(cid:105) is the only relation from the disjoint union S + T
to X such that (cid:104)α, β(cid:105) ◦ i1 = α and (cid:104)α, β(cid:105) ◦ i2 = β.

The product of two sets S and T in Rel is also the disjoint union S + T .
It must be that because that is the sum and Rel is isomorphic to Rel op
(Exercise 6 of 3.3). It follows that p1 = {((s, 0), s) | s ∈ S} (the opposite of
the graph of i1) and similarly for p2.

The product of S and T in Pfn is quite diﬀerent: it is the disjoint union

S × T + S + T . The projection p1 is deﬁned by






p1(r) =

s
r
undeﬁned otherwise

if r = (s, t) ∈ S × T
if r ∈ S

5.4.8 Finite sums in programming languages
In 5.3.14, we have de-
scribed products in the category corresponding to a programming language
as records. Sums play a somewhat subtler role.

If A and B are types, the sum A + B can be thought of as the free
variant or free union of the types A and B. If we are to take this seriously,

182

Products and sums

we have to consider the canonical structure maps i1 : A −→ A + B and i2 : B
−→ A + B. These are type conversions; i1 converts something of type A
to something of the union type. Such type conversions are not explicit in
languages such as Pascal or C, because in those languages, the free union
is implemented in such a way that the type conversion i1 : A −→ A + B can
always be described as ‘use the same internal representation that it has when
it is type A’. Thus in those languages, the eﬀect of an operation with domain
‘A + B’ is implementation-dependent.

Thus sums and products provide some elementary constructions for functional
programming languages. Still missing are some constructions such as IF...THEN...ELSE
and WHILE loops or recursion which give the language the full power of a Tur-
ing machine. IF...THEN...ELSE is discussed in Sections 5.7 and 9.6.1. Some
approaches to recursion are discussed in 6.6 and 14.2. Wagner [1986a, 1986b]
discusses these constructions and others in the context of more traditional im-
perative programming languages.

5.4.9 Exercises

1. For f : S −→ S(cid:48) and g : T −→ T (cid:48) in a category with sums, the arrow f + g :
S + T −→ S(cid:48) + T (cid:48) is the unique arrow making the opposite of Diagram (5.14)
commute. Describe this construction in Set.

2. Show that the sum of two elements in a poset is the least upper bound
of the elements.

3. Describe the sum of two posets in the category of posets and monotone
maps.

4. Show that the sum of two sets S and T in Pfn is the disjoint union S + T
(see 5.4.5).

5. Give an example of a category containing a sum with the property that
one of the ‘canonical injections’ is not monic.

5.5 Natural numbers objects

Virtually all the categorical models for programming language semantics
suppose there is an object of the category that allows a recursive deﬁnition
of arrows. To deﬁne such an object, we must suppose that the category has
a terminal object, which we denote by 1.

5.5.1 Deﬁnition An object N, an arrow zero : 1 −→ N and an arrow succ :
N −→ N constitute a natural numbers object in a category C if given any

object A, any arrow f0 : 1 −→ A and any arrow t : A −→ A, there is then a
unique arrow f : N −→ A such that the following diagram commutes:

5.5 Natural numbers objects

183

zero

(cid:161)(cid:181)

(cid:161)

1
f0(cid:64)

(cid:64)(cid:82)

N

N(cid:45)succ

f

(cid:63)
A

f

(cid:63)
A(cid:45)

t

(5.28)

5.5.2 Example A natural numbers object in C is exactly an initial model
in C of the sketch of Example 4.7.7 (Exercise 2). In particular, the set N of
natural numbers with zero = 0 and succ the successor function is a natural
numbers object in Set. Let the function zero choose the element 0 ∈ N
and let succ be the usual successor function, which we will denote by s.
For any set A, a function 1 −→ A is an element we may call a0 ∈ A. The
commutation of the triangle forces that f (0) = a0 and then we have that
f (1) = f (s0) = t ◦ f (0) = t(a0), f (2) = f (s1) = t ◦ f (1) = t2(a0) and so on.
Thus we can show by induction that any function f making the diagram
commute must satisfy f (n) = tn(a0). This proves both the existence and the
uniqueness of f .

In practice, this deﬁnition is not strong enough to be really useful and

must be strengthened as follows.

5.5.3 Deﬁnition An object N in a category C together with arrows zero :
1 −→ N and succ : N −→ N is called a stable natural numbers object if for all
objects A and B and arrows f0 : B −→ A and t : A −→ A, there is a unique
arrow f : B × N −→ A such that

(cid:104)idB, zero(cid:105)

(cid:161)

B

(cid:64)
f0

B × N
(cid:161)(cid:161)(cid:181)

f

(cid:64)(cid:64)(cid:82)

(cid:63)
A

idB × succ

(cid:45)

B × N

f

(cid:63)
A(cid:45)

t

commutes. When B = 1, this reduces to the previous deﬁnition. We think
of B as an object of parameters. For this reason, an N that satisﬁes this
deﬁnition is sometimes called a parametrized natural numbers object, even
though it is not N that is parametrized.

184

Products and sums

This deﬁnition is equivalent to the statement that the product projection
B ×N −→ B is a natural numbers object in the category C /B for every object
B. Thus we are using ‘stable’ in its usual sense of ‘invariant under slicing’.

5.5.4 Remark In many sources, what we have called a stable natural
numbers object is called, simply, a natural numbers object and the weaker
concept is given no name. The reason for this is that the concept was orig-
inally deﬁned in cartesian closed categories (the subject of Chapter 6) and
in such categories the two notions coincide; see Proposition 6.2.5. In truth,
natural numbers objects that are not stable are not very useful.

5.5.5 Theorem Let C be a category with a terminal object 1 and N a
sum of countably many copies of 1. Then N satisﬁes the speciﬁcation of a
natural numbers object.

Proof. Let ui : 1 −→ N be the element of the cocone corresponding to the ith
copy of the sum. Let s : N −→ N be the unique arrow deﬁned by the formula
s ◦ ui = ui+1. That is the arrow s is the unique arrow such that for each i,
the diagram

s
commutes. Now suppose t : A −→ A is an endomorphism and f0 : 1 −→ A is
a global element. We deﬁne a sequence of arrows fn : 1 −→ A by ordinary
induction by letting f0 be the given map and fn+1 = t ◦ fn. Then we use
the universal property of the sum to deﬁne f : N −→ A by f ◦ un = fn. The
commutativity of

1

(cid:64)

ui

(cid:64)

(cid:63)
N

ui+1
(cid:64)
(cid:64)(cid:82)
N(cid:45)

(cid:161)(cid:181)
0(cid:161)

1
f0(cid:64)

(cid:64)(cid:82)

N

f

(cid:63)
A

N(cid:45)s

f

(cid:63)
A(cid:45)

t

is evident. To show uniqueness, suppose g : N −→ A is an arrow such that

u0(cid:161)
(cid:161)(cid:181)
1
f0(cid:64)

(cid:64)(cid:82)

N

g

(cid:63)
A

N(cid:45)s

g

(cid:63)
A(cid:45)

t

5.5 Natural numbers objects

185

commutes, then the commutativity of the triangle implies that g ◦ u0 = f0
and if we suppose inductively that g ◦ un = fn = f ◦ un, then

g ◦ un+1 = g ◦ s ◦ un = t ◦ g ◦ un = t ◦ fn = fn+1 = f ◦ un+1

But then it follows by the uniqueness of arrows from a sum that f = g.

5.5.6 There are two comments we would like to make about Theorem 5.5.5.
First, there is a question of whether assuming countable sums is com-
putationally plausible as a model of programming language semantics. We
are not talking about the fact that computers are ﬁnite. Despite that, it
is a reasonable idealization (and common practice) to allow computational
models that, in principle at least, allow indeﬁnitely large objects.

The problem is that these computations, although potentially inﬁnite,
should be ﬁnitely describable. Thus a function from natural numbers to
natural numbers can be imagined computable if it can be described by a
ﬁnite formula in some sense of the word formula. Since a formula can be
described with a ﬁnite alphabet in a ﬁnite way, one can show that only
countably many such formulas exist. On the other hand, if a countable sum
of copies of 1 exists, that sum N can be shown to admit uncountably many
functions to itself. It is evident that most of these cannot be given by a
formula and make no sense in a model of computation.

Although one cannot actually prove it (owing to imprecision in the notion
‘formula’), it seems likely that the class of functions that are computation-
ally reasonable is just the class of recursive functions (Church’s thesis). (See
[Lewis and Papadimitriou, 1981], Section 5.1, where recursive functions are
called µ-recursive.) One should look on a natural numbers object as a com-
putationally meaningful substitute for a countable sum of copies of 1.

The real reason that this theorem is interesting is that it tells us some-
thing about the strength of the hypothesis of existence of a natural numbers
object; it is weaker than the assumption of existence of countable sums and
that is usually considered by category theorists to be fairly weak. Of course,
we have just argued above that it is fairly strong, but at any rate the hy-
pothesis of a natural numbers object is weaker.

The second comment is that the construction in Theorem 5.5.5 does not
generally give stable natural numbers. Many familiar categories, for example
the category of semigroups, have countable (in fact arbitrary) sums and a
terminal object and so a natural numbers object which, however, is not sta-
ble. In Proposition 6.2.5 and in Section 9.6, Exercise 7, we will see additional
assumptions that force the existence of a stable natural numbers object.

In Section 14.2, we study the concept of a locally recursive category,
which has a stronger property that implies that it has a natural numbers
object.

186

Products and sums

5.5.7 Restricted natural numbers objects James R. Otto studied in
his doctoral dissertation, [Otto, 1995], what might be called restricted nat-
ural numbers objects. These are objects (cid:101)N , equipped with (cid:103)zero : 1 −→ (cid:101)N
and (cid:103)succ : (cid:101)N −→ (cid:101)N that have the uniqueness, not necessarily the existence
expressed in the Deﬁnition 5.5.1. The eﬀect of computation with such re-
stricted natural numbers objects is that only a subset of functions can be
computed. With various kinds of restricted NNOs one can ﬁnd models of
restricted recursion in which the constructible functions are, for example,
those that can be computed in polynomial time, or that require polynomial
space.

5.5.8 Exercises

1. Show that the natural numbers, with zero and the successor function,
form a stable natural numbers object in Set.

2. Show that a natural numbers object in a category is a model of the sketch
of Example 4.7.7 in that category. Show that it is in fact an initial model.

3. Suppose N is a stable natural numbers object in some category and A
and B are arbitrary objects. Show that given any arrows g : B −→ A and h :
B ×N×A −→ A, there is a unique f : B ×N −→ A such that f (b, 0) = g(b) and
f (b, sn) = h(b, n, f (b, n)). (This uses variable element notation, as discussed
in 2.8.2. It is a great convenience here.) This is the usual formulation of
induction, except that B is usually taken to be the cartesian product of a
ﬁnite number of copies of N. (The way to do this is to ﬁnd an appropriate
arrow t from B × N × A to itself, to deﬁne k0 : B −→ B × N × A by k0(b) =
(b, 0, g(b)) and then let k : B × N −→ B × N × A be the unique arrow so that

idB × succ

(cid:45)

B × N

B × N
(cid:161)(cid:181)

(cid:161)

(cid:104)idB, zero(cid:105)
(cid:161)

B

k

k

(cid:64)
k0

(cid:64)

(cid:64)(cid:82)

(cid:63)
B × N × A

(cid:45)

(cid:63)
B × N × A

t

commutes. Then set f = p3 ◦ k.)

5.6 Deduction systems as categories

In this section, we describe brieﬂy the connection between formal logical
systems and categories.

5.6 Deduction systems as categories

187

5.6.1 A deduction system has formulas and proofs. The informal idea
is that the formulas are statements, such as x ≤ 7, and the proofs are valid
lines of reasoning starting with one formula and ending with another; for
example, it is valid in high school algebra (which is a deductive system) to
prove that if x ≤ 7 then 2x ≤ 14. We will write a proof p which assumes A
and deduces B as p : A −→ B.

Typically, formal deduction systems deﬁne the formulas by some sort of
context free grammar, a typical rule of which might be: ‘If A and B are
formulas, then so is A ∧ B’. The valid proofs are composed of chains of
applications of certain speciﬁed rules of inference, an example of which
might be: ‘From A ∧ B it is valid to infer A’.

5.6.2 Assumptions on a deduction system As in the case of func-
tional programming languages (see 2.2.4), certain simple assumptions on a
deduction system, however it is deﬁned, produce a category.

DS–1 For any formula A there is a proof idA : A −→ A.
DS–2 Proofs can be composed: if you have proofs p : A −→ B and q : B −→ C

then there is a valid proof p; q : A −→ C.

DS–3 If p : A −→ B is a proof then p; idB and idA; p are both the same proof

as p.

DS–4 If p, q and r are proofs, then (p; q); r must be the same proof as p; (q; r),

which could be denoted p; q; r.

These requirements clearly make a deduction system a category.

One could take a deduction system and impose the minimum require-
ments just given to produce a category. One could on the other hand go
all the way and make any two proofs A to B the same. In that case, each
arrow in the category stands for the usual notion of deducible. The choice of
an intermediate system of identiﬁcation could conceivably involve delicate
considerations.

5.6.3 Deﬁnition A conjunction calculus is a deduction system with a
formula true and a formula A ∧ B for any formulas A and B, which satisﬁes
CC–1 through CC–5 below for all A and B.

CC–1 There is a proof A −→ true.
CC–2 If u : A −→ true and v : A −→ true are proofs, then u = v.
CC–3 There are proofs p1 : A ∧ B −→ A and p2 : A ∧ B −→ B with the
property that given any proofs q1 : X −→ A and q2 : X −→ B there is
a proof (cid:104)q1, q2(cid:105) : X −→ A ∧ B.

CC–4 For any proofs q1 : X −→ A and q2 : X −→ B, p1 ◦ (cid:104)q1, q2(cid:105) = q1 and

p2 ◦ (cid:104)q1, q2(cid:105) = q2.

188

Products and sums

CC–5 For any proof h : Y −→ A ∧ B, (cid:104)p1 ◦ h, p2 ◦ h(cid:105) = h.

It is straightforward (Exercise 1) to prove that category corresponding
to a conjunction calculus has ﬁnite products, with true the terminal object
and ∧ the binary product.

Similar constructions may be made using sums to get a disjunction calcu-
lus. Cartesian closed categories (the subject of Chapter 6) give an implication
operator and quantiﬁers are supplied in a topos (Chapter 15). These topics
are pursued in detail in [Lambek and Scott, 1986], [Makkai and Reyes, 1977]
and [Bell, 1988].

5.6.4 Exercises

1. Prove that equations CC–1 through CC–5 make the given deduction sys-
tem a category with ﬁnite products.

2. Prove that in any conjunction calculus, for any objects A, B and C, there
are proofs

a. A ∧ A −→ A.
b. A −→ A ∧ A.
c. A ∧ B −→ B ∧ A.
d. (A ∧ B) ∧ C −→ A ∧ (B ∧ C).

5.7 Distributive categories

Distributive categories, roughly speaking categories in which products dis-
tribute over sums, have been proposed as suitable semantics for programs,
particularly those aspects involving control (if then else). We introduce them
here and describe some examples and applications. Walters [1991] (see also
[Walters, 1992]) gives many applications in detail, and Cockett [1993] pro-
vides an extensive description of the theory of distributive categories. See
also [Kasangian and Vigna, 1991].

Let C be a category with binary products and binary sums. Then for

any objects A, B and C we have sum cocones

(cid:45)i1

B

B + C

C(cid:190)i2

and

(cid:45)i(cid:48)

1

A×B

A×B+A×C

(cid:190)i(cid:48)

2

A×C

5.7 Distributive categories

189

There is then an arrow d : A × B + A × C −→ A × (B + C) that is the unique
arrow making

(cid:45)i(cid:48)

1

A×B

A×B+A×C

(cid:190)i(cid:48)

2

A×C

(cid:64)

(cid:64)
A×i1

(cid:64)

(cid:64)

d

(cid:161)

(cid:161)

(cid:64)(cid:82)

(cid:63)
A×(B + C)

(cid:161)(cid:170)

(cid:161)

(cid:161)
A×i2

(5.29)

commute.

5.7.1 Deﬁnition A distributive category is a category with ﬁnite sums
and ﬁnite products in which for all objects A, B and C, the arrow d deﬁned
by Diagram (5.29) is an isomorphism.

5.7.2 Remark For an object A in a distributive category, deﬁne the func-
tor A × − as follows: for an object B, the value is A × B; for an arrow f , the
value is idA ×f . The deﬁnition of distributive category then says that A × −
preserves binary sums.

The fact that we assume that the category has ﬁnite sums and products
instead of merely binary sums and products means that it has an initial
object and a terminal object (Deﬁnition 5.3.9 and its dual). As before, the
initial object is denoted 0 and the unique map from 0 to an object A is
denoted ! : 0 −→ A. The terminal object is denoted 1 and the unique map to
1 from an object A is denoted (cid:104)(cid:105) : A −→ 1. Many authors use ⊥ for 0 and (cid:62)
for 1.

Some other consequences of the deﬁnition are given by the following
proposition. Part (ii) refers to the unique map (cid:104)id0, !(cid:105) that makes this dia-
gram commute:

0

(cid:161)

id0
(cid:161)
(cid:161)(cid:170)
(cid:190)

p1

0

(cid:64)
(cid:161)
(cid:104)id0, !(cid:105)
(cid:63)
0×A

(cid:64)

!
(cid:64)
(cid:64)(cid:82)
A(cid:45)

p2

(5.30)

5.7.3 Proposition Let C be a distributive category. Then

(i) Every canonical injection i1 : A −→ A + B and i2 : B −→ A + B is

monic.

190

Products and sums

(ii) For every object A, the arrow (cid:104)id0, !(cid:105) : 0 −→ 0 × A is an isomorphism.

Note that (ii) implies by Proposition 5.3.13 that any distributive category
has a strict initial object. In conjunction with 5.7.2 it also shows that the
functor A × − preserves ﬁnite sums.

We will prove (ii). This proof gives a good workout of the ideas of this
chapter. The proof of (i) uses similar techniques and may be found in [Cock-
ett, 1993].

Proof. We ﬁrst observe that in the sum diagram

0 −→ 0 + 0 ←− 0

both sum injections are equal to ! because 0 is initial. Now consider

(cid:45)i1

0×A

0×A + 0×A

(cid:190)i2

0×A

(cid:64)

(cid:64)
!× idA

(cid:64)

(cid:161)

(cid:161)
!× idA

(cid:161)

d

(cid:64)

(cid:161)

(cid:64)(cid:82)

(cid:63)
(0 + 0)×A

(cid:161)(cid:170)

Since d is an isomorphism, it follows that i1 = i2.

Suppose f, g : 0 × A −→ X are arrows. Then the sum diagram

(cid:45)i1

0×A

0×A + 0×A

(cid:190)i2

0×A

(cid:64)

(cid:64)
f

(cid:64)

(cid:104)f |g(cid:105)

(cid:161)

(cid:161)
g

(cid:161)

(cid:64)

(cid:161)

(cid:64)(cid:82)

(cid:63)
(0 + 0)×A

(cid:161)(cid:170)

shows that f = g. Therefore, there is at most one arrow from 0 × A to any
given object. Finally, the composite

0 × A

proj1
−−−−−→ 0

!

−→ X

shows that there is at least one arrow from 0 × A to a given object. Thus
0 × A is an initial object.

5.7.4 Example Set is distributive. If B and C are disjoint, the map d :
A × B + A × C −→ A × (B + C) is the identity map and so has an inverse. If
they are not disjoint, then for a ∈ A, b ∈ B and c ∈ C, using the deﬁnition
of disjoint union in 5.4.5, d((a, b), 0) = (a, (b, 0)) and d((a, c), 1) = (a, (c, 1)).
Its inverse is then deﬁned by d−1(a, (b, 0)) = ((a, b), 0) and d−1(a, (c, 1)) =
((a, c), 1).

5.7 Distributive categories

191

5.7.5 Boolean algebras A poset B is a Boolean algebra if

BA–1 For all x, y ∈ B, there is a least upper bound (supremum) x ∨ y.
BA–2 For all x, y ∈ B, there is a greatest lower bound (inﬁmum) x ∧ y.
BA–3 ∧ distributes over ∨: for all x, y, z ∈ B,

x ∧ (y ∨ z) = (x ∧ y) ∨ (x ∧ z)

BA–4 B contains two elements 0 and 1 that are the least and greatest ele-

ments of B respectively.

BA–5 Each element x has a complement ¬x, meaning that x ∧ ¬x = 0 and

x ∨ ¬x = 1.

It follows that a Boolean algebra has all ﬁnite (including empty) inﬁmums
and supremums, that both operations ∧ and ∨ are commutative and asso-
ciative and that ∨ distributes over ∧. (That these properties follow from
BA–1 through BA–5 is not entirely trivial to show.) A Boolean algebra B is
trivial if 0 = 1; in that case B contains only one element.

The category corresponding to a Boolean algebra is distributive. Note
that the extra distributive law that holds in Boolean algebras does not hold
in all distributive categories; in particular, the equation A + (B × C) = (A +
B) × (A + C) is in general false in Set.

5.7.6 The object of truth values Suppose this is a sum cocone

B(cid:45)true

(cid:190)false

1

1

Of course, this makes B isomorphic to 1 + 1, but we call it B because of the
role it will play in giving semantics to programs.

Using B, one can simulate ‘if–then–else’ and similar control functions.
Suppose, for example, that we have arrows f, g : C −→ D and a test function
b : T −→ B ∼= 1 + 1. We want to construct an arrow h : C × T −→ D such that
h(c, t) = f (c) if b(t) = true and h(c, t) = g(c) if b(t) = false. The composite
arrow below has that property, provided one interprets expressions such as
f (c) as f ◦ c where c is a global element of C.

C×T

idC ×b

−−−−−−→ C×B

d−1

−−−→ C×1 + C×1

p1 + p2

−−−−−−→ C + C

f + g

−−−−−→ D + D

(cid:104)idD | idD(cid:105)

−−−−−−−−−→ D

(This example is due to Walters [1991].)

192

Products and sums

5.7.7 Truth tables One can also combine such tests using Boolean oper-
ations. In a distributive category, any truth table, for example

P
true
true
false
false

Q
true
false
true
false

P &Q
true
false
false
false

corresponds to an arrow from B × B to B. To see how this works, consider
this diagram, in which the ik, i(cid:48)
k and jk are the injections for the sums shown.
We have shown only j2 of the four injections into 1 + 1 + 1 + 1.

(cid:45)j2

1 + 1 + 1 + 1

(cid:104)(cid:104)true | false(cid:105)|(cid:104)true | false(cid:105)(cid:105)
(cid:63)
B + B

(cid:45)i1

(cid:190) i2

B

false

1

(cid:63)
B

(cid:104)(cid:104)(cid:105), idB(cid:105)

(cid:63)
1×B

i(cid:48)
(cid:72)(cid:72)
1
true × idB

(cid:104)(cid:104)(cid:105), idB(cid:105) + (cid:104)(cid:104)(cid:105), idB(cid:105)
(cid:63)
1×B + 1×B
1×B + 1×B

(cid:190)

(cid:45)
(cid:45)

(cid:104)(cid:104)(cid:105), idB(cid:105)
(cid:63)
1×B

i(cid:48)
(cid:169)(cid:169)
2
(cid:169)(cid:169)(cid:169)(cid:169)(cid:188)
false × idB

(cid:72)(cid:72)(cid:72)(cid:72)(cid:106)

(cid:63)
B×B

(5.31)

Call the central vertical arrow in this diagram φ : 1 + 1 + 1 + 1 −→ B × B.
φ is a composite of isomorphisms. It is an exercise in diagram chasing to
show that φ ◦ j2 = (cid:104)true, false(cid:105) : 1 −→ B × B. Similarly, j1 = (cid:104)true, true(cid:105),
j3 = (cid:104)false, true(cid:105) and j4 = (cid:104)false, false(cid:105). If we now construct the function
(cid:104)true | false | false | false(cid:105) : 1 + 1 + 1 + 1 −→ B, then

q = (cid:104)true | false | false | false(cid:105) ◦ φ−1 : B × B −→ B

satisﬁes q ◦ (cid:104)true, true(cid:105) = true, and q composed with the other three com-
binations gives false, so that q is essentially the operation of conjunction
on B. All the binary operations on B that correspond to truth tables can
be constructed in this way. (Indeed, any function between ﬁnite sets can be
simulated in this way.) As a result, B plays the role of a Boolean algebra in
the category C .

5.7.8 Using Boolean operations Using the arrow q just deﬁned, we can
modify the example in 5.7.6 to employ two Boolean tests b1 and b2, where

5.7 Distributive categories

193

h(c, t1, t2) = f (c) if and only if both b1(t1) and b2(t2) are true. This arrow
does that:

C × T × T

idC ×b1 × b2

−−−−−−−−−−→ C × B × B

idc ×q

−−−−−→ C × B

d1−−→ C×1 + C×1

p1 + p1

−−−−−−→ C + C

f + g

−−−−−→ D + D

(cid:104)idD | idD(cid:105)

−−−−−−−−−→ D

5.7.9 Exercises

1. Show that Rel and Mon are not distributive categories.

2. In a category with ﬁnite sums, a sum A + B + C is deﬁned using the dual
of Diagram (5.20), page 169. Using this notation, show that in a distributive
category, D × (A + B + C) ∼= D × A + D × B + D × C.

3. This exercise shows how to implement cases in a distributive category.
Given an arrow c : T −→ 1 + 1 + 1 and arrows f, g, h : C × T −→ D, show
how to implement a function h : C × T −→ D that has value f (c), g(c) or
h(c) depending on whether c(t) is in the ﬁrst, second or third summand of
1 + 1 + 1.

6
Cartesian closed categories

A cartesian closed category is a type of category that as a formal system has
the same expressive power as a typed λ-calculus. In Sections 6.1 and 6.2, we
deﬁne cartesian closed categories and give some of their properties. In Sec-
tion 6.3, we describe the concept of typed λ-calculus. Section 6.4 describes
the constructions involved in translating from one formalism to the other,
without proof. Section 6.5 discusses the issues and technicalities involved
in translating between a term in the λ-calculus and an arrow in the cor-
responding category. Section 6.6 describes the construction of ﬁxed points
of endomorphisms of an ω-complete partially ordered object in a cartesian
closed category. This is used to provide a semantics for If and While loops.
Section 6.6 may be read immediately after Section 6.4.

Sections 6.1 and 6.2 are needed for Chapter 15. Monoidal closed cat-
egories, discussed in Chapter 16, are a generalization of cartesian closed
categories, but the discussion in Chapter 16 is independent of this chapter.
Other than for the chapters just mentioned, this chapter is not needed in
the rest of the book.

Most of the cartesian closed categories considered in computer science
satisfy a stronger property, that of being ‘locally cartesian closed’, which is
discussed in Section 13.4.

A basic reference for cartesian closed categories and their connection
with logic is [Lambek and Scott, 1986]. See also [Huet, 1986] and [Mitchell
and Scott, 1989]. The text by Gunter [1992] gives a systematic treatment
of programming language semantics in terms of the ideas of this chapter.
Substantial applications to computing may be found in [Cousineau, Curien
and Mauny, 1985], [Curien, 1986], [Hagino, 1987b] and [Dybkjaer and Mel-
ton, 1993].

In this chapter and later, we frequently use the name of an object to
stand for the identity arrow on the object: thus ‘A’ means ‘idA’. This is
common in the categorical literature because it saves typographical clutter.

6.1 Cartesian closed categories

6.1.1 Functions of two variables
If S and T are sets, then an element
of S × T can be viewed interchangeably as a pair of elements, one from S

195

196

Cartesian closed categories

and one from T , or as a single element of the product. If V is another set,
then a function f : S × T −→ V can interchangeably be viewed as a function
of a single variable ranging over S × T or as a function of two variables, one
from S and one from T . Conceptually, we must distinguish between these
two points of view, but they are equivalent.

In a more general category, the notion of function of two variables should
be understood as meaning an arrow whose domain is a product (see 5.2.6).
Under certain conditions, such a function can be converted to a function of
one variable with values in a ‘function object’. We now turn to the study of
this phenomenon.

6.1.2 To curry a function of two variables is to change it into a function
of one variable whose values are functions of one variable. Precisely, let S,
T and V be sets and f : S × T −→ V a function. Let [S −→ T ] denote the
set of functions from S to T . Then there is a function λf : S −→ [T −→ V ]
deﬁned by letting λf (s) be the function whose value at an element t ∈ T
is f (s, t). The passage from f to λf is called currying f . As an example,
the deﬁnition on arrows of the functor Fα obtained from a monoid action as
in 3.2.3 is obtained by currying α.

In the other direction, if g : S −→ [T −→ V ] is a function, it induces a
function f : S × T −→ V deﬁned by f (s, t) = [g(s)](t). This construction
produces an inverse to λ that determines an isomorphism

HomSet(S × T, V ) ∼= HomSet(S, [T −→ V ])

These constructions can readily be stated in categorical language. The re-
sult is a theory that is equivalent to the typed λ-calculus (in the sense of
Section 6.3) and has several advantages over it.

6.1.3 Deﬁnition A category C is called a cartesian closed category if
it satisﬁes the following:

CCC–1 There is a terminal object 1.
CCC–2 Each pair of objects A and B of C has a product A × B with pro-

jections p1 : A × B −→ A and p2 : A × B −→ B.

CCC–3 For every pair of objects A and B, there is an object [A −→ B] and
an arrow eval : [A −→ B] × A −→ B with the property that for any
arrow f : C × A −→ B, there is a unique arrow λf : C −→ [A −→ B]
such that the composite

C × A

λf × A

−−−−−−→ [A −→ B] × A

eval

−−−−→ B

is f .

6.1 Cartesian closed categories

197

6.1.4 Terminology Traditionally, [A −→ B] has been denoted BA and
called the exponential object, and A is then called the exponent. The
exponential notation is motivated by the following special case: if C is the
category of sets and n = {0, 1, . . . , n − 1}, the standard set with n elements,
then Bn is indeed the set of n-tuples of elements of B.

In CCC–3, there is a diﬀerent arrow eval for each pair of objects A and B.
When necessary, we will write the arrow eval : [A −→ B] × A −→ B as evalA
B.
This collection of arrows for a ﬁxed A forms the counit of an adjunction, as
deﬁned in 13.2.5. Because of that, λf is often called the adjoint transpose
of f .

6.1.5 In view of Proposition 5.3.10, CCC–1 and CCC–2 could be replaced
by the requirement that C have ﬁnite products. There is a slight notational
problem in connection with this. We have used p1 and p2 for the two pro-
jections of a binary product. We will now use

(cid:89)

pj :

Ai −→ Aj

for j = 1, . . . , n to denote the jth projection from the n-ary product. This
usage should not conﬂict with the previous usage since it will always be clear
what the domain is.

A related problem is this. Condition CCC–3 appears to treat the two fac-
tors of C × A asymmetrically, which is misleading since of course C × A ∼=
A × C. Products are of indexed sets of objects (see 5.1.3) not necessarily
indexed by an ordered set, even though our notation appears to suggest oth-
erwise. It gets even worse with n-ary products, so we spell out the notation
we use more precisely.

6.1.6 Proposition For any objects A1,. . . , An and A of a cartesian closed
category and any i = 1,. . .,n, there is an object [Ai −→ A] and an arrow

eval : [Ai −→ A] × Ai −→ A

such that for any f :

(cid:81)

Aj −→ A, there is a unique arrow

λif :

(cid:89)

j(cid:54)=i

Aj −→ [Ai −→ A]

198

Cartesian closed categories

such that the following commutes:

(cid:81)

Aj

(cid:64)

(cid:64)

(cid:104)λif ◦ (cid:104)p1, . . . , pi−1, pi+1, . . . , pn(cid:105), pi(cid:105)

(cid:64)

(cid:64)

f
(cid:64)

(cid:63)
[Ai −→ A] × Ai

(cid:64)

eval

(cid:64)

(cid:64)(cid:82)
A(cid:45)

In Set, λif gives a function from Ai to A for each (n − 1)-tuple

(a1, a2, . . . , ai−1, ai+1, . . . , an)

6.1.7 Evaluation as universal element For ﬁxed objects A and B of
a cartesian closed category, let FA,B denote the functor Hom(− × A, B),
so that if g : D −→ C, FA,B(g) : Hom(C × A, B) −→ Hom(D × A, B) takes
f : C × A −→ B to f ◦ (g × A). CCC–3 says that eval : [A −→ B] × A −→ B is
a universal element for FA,B. This is true for every object A and B and by
Proposition 4.5.12 implies that the maps f (cid:55)→ λf form a natural isomorphism
of functors:

Hom(− × A, B) ∼= Hom(−, [A −→ B])

(6.1)

It follows that a category with ﬁnite products can be a cartesian closed
category in essentially only one way. The following proposition makes this
precise. It is a special case of the fact that adjoints are essentially unique
(see 13.3.4).

6.1.8 Proposition Let C be a category with ﬁnite products. Suppose that
for every pair of objects A and B, there are objects [A −→ B] and [A −→ B](cid:48)
and arrows eval : [A −→ B]×A −→ B and eval(cid:48) : [A −→ B](cid:48) ×A −→ B. Suppose
these have the property that for any arrow f : C × A −→ B, there are unique
arrows λf : C −→ [A −→ B], λ(cid:48)f : C −→ [A −→ B](cid:48) for which eval ◦ (λf ×A) =
eval(cid:48) ◦ (λ(cid:48)f × A) = f . Then for all objects A and B, there is a unique arrow
φ(A, B) : [A −→ B](cid:48) −→ [A −→ B] such that for every arrow f : C × A −→ B

6.1 Cartesian closed categories

199

the following diagrams commute:

[A −→ B](cid:48) × A

(cid:64)

(cid:64)

eval(cid:48)
(cid:64)
(cid:64)(cid:82)

B

φ(A, B) × A

C

λ(cid:48)f
(cid:161)

(cid:161)

[A −→ B](cid:48)
(cid:161)(cid:181)

(cid:161)

φ(A, B)

(cid:161)(cid:181)
(cid:161)
eval

(cid:161)

(cid:63)
[A −→ B] × A

(cid:161)

(cid:64)
λf

(cid:64)

(cid:64)

(cid:64)(cid:82)
(cid:63)
[A −→ B]

Moreover, φ is an isomorphism.

6.1.9 Example The ﬁrst example of a cartesian closed category is the
category of sets. For any sets A and B, [A −→ B] is the set of functions
from A to B, and evalA
B is the evaluation or apply function. The meaning
of λf is discussed above in 6.1.2. Note that in the case of Set, [A −→ B] is
HomSet(A, B).

6.1.10 Example A Boolean algebra (see 5.7.5) B is a poset, so corre-
sponds to a category C(B). This category is a cartesian closed category.
The terminal object of a Boolean algebra B is 1, so C(B) satisﬁes CCC–1.
Since B has the inﬁmum of any two elements, C(B) has binary products
(see 5.1.8) and so satisﬁes CCC–2.

To prove CCC–3, deﬁne [a −→ b] to be ¬a ∨ b. To show that evala

b exists
requires showing that [a −→ b] ∧ a ≤ b. This can be seen from the following
calculation, which uses the distributive law:

[a −→ b] ∧ a = (¬a ∨ b) ∧ a

= (¬a ∧ a) ∨ (b ∧ a)

= 0 ∨ (b ∧ a) = b ∧ a ≤ b

The existence of the λ function requires showing that if c ∧ a ≤ b then c ≤ [a
−→ b] (the uniqueness of λf and the fact that eval ◦ λf ×A = f are automatic
since no hom set in the category determined by a poset has more than one
element). This follows from this calculation, assuming c ∧ a ≤ b:

c = c ∧ 1 = c ∧ (a ∨ ¬a)

= (c ∧ a) ∨ (c ∧ ¬a)

≤ b ∨ (c ∧ ¬a) ≤ b ∨ ¬a = [a −→ b]

200

Cartesian closed categories

6.1.11 Example A poset with all ﬁnite (including empty) infs and sups
that is cartesian closed as a category is called a Heyting algebra. A Heyt-
ing algebra is thus a generalization of a Boolean algebra. Heyting algebras
correspond to intuitionistic logic in the way that Boolean algebras corre-
spond to classical logic. A Heyting algebra is complete if it has sups of all
subsets. We use this concept in Chapter 15 (see Exercise 1 of Section 15.5).
A thorough exposition of the elementary properties of Heyting algebras may
be found in [Mac Lane and Moerdijk, 1992], section I.8.

6.1.12 Example The category whose objects are graphs and arrows are
homomorphisms of graphs is also cartesian closed. If G and H are graphs,
then the exponential [G −→ H ] (which must be a graph) can be described as
follows. Let No denote the graph consisting of a single node and no arrows
and Ar the graph with one arrow and two distinct nodes, the nodes being
the source and the target of the arrow.

There are two embeddings of No into Ar, which we will call s, t : No
−→ Ar, that take the single node to the source and target of the arrow of
Ar, respectively. Then [G −→ H ] is the graph whose set of nodes is the set
Hom(G × No, H ) of graph homomorphisms from G × No to H and whose
set of arrows is the set Hom(G × Ar, H ) with the source and target functions
given by Hom(G × s, H ) and Hom(G × t, H ), respectively. In Exercise 3,
we give a more elementary description of the cartesian closed structure. The
description given here is a special case of a general result on categories of
set-valued functors in 6.1.13 below.

Note that in the case of graphs, the object [G −→ H ] is not the set
Hom(G , H ) with the structure of a graph imposed on it in some way. Since
[G −→ H ] is an object of the category, it must be a graph; but neither its set
of objects nor its set of arrows is Hom(G , H ). In particular, to prove that
a category of sets with structure is not cartesian closed, it is not enough to
prove that an attempt to put a structure on the hom set must fail.

6.1.13 Example If C is a small category then Func(C , Set) is a cate-
gory; the objects are functors and the arrows are natural transformations.
(See 4.3.1.) Func(C , Set) is a cartesian closed category. If F , G : C −→ Set
are two functors, the product F × G was deﬁned in 5.2.20. The exponential
object [F −→ G] is the following functor. For an object C, [F −→ G](C) is
the set of natural transformations from the functor Hom(C, −) × F to G.
For f : C −→ D an arrow of C and α : Hom(C, −) × F −→ G a natural trans-
formation, [F −→ G](f )(α) has component at an object A that takes a pair
(v, x) with v : D −→ A and x ∈ F (A) to the element αA(v ◦ f, x) of G(A).
See [Mac Lane and Moerdijk, 1992], page 46 for a proof of a more general
theorem of which this is a special case.

6.1 Cartesian closed categories

201

Example 6.1.12 is a special case of this example. This also implies, for
example, that the category of u-structures described in 4.2.5 is cartesian
closed, as is the arrow category of Set (see 4.2.17).

6.1.14 Example The category Cat of small categories and functors is
cartesian closed. In this case, we have already given the construction in 4.3.1:
for two categories C and D, [C −→ D] is the category whose objects are
functors from C to D and whose arrows are natural transformations between
them.

If F : B × C −→ D is a functor, then λF : B −→ [C −→ D] is the
functor deﬁned this way: if B is an object of B, then for an object C
of C , λF (B)(C) = F (B, C), and for an arrow g : C −→ C(cid:48), λF (B)(g) is
the arrow F (B, g) : (B, C) −→ (B, C(cid:48)) of D. For an arrow f : B −→ B(cid:48) of B,
λF (f ) is the natural transformation from λF (B) to λF (B(cid:48)) with component
λF (f )(C) = F (f, C) at an object C of C . It is instructive to check that this
does give a natural transformation.

6.1.15 Example The category consisting of ω-CPOs (2.4.3) and contin-
uous functions is a cartesian closed category, although the subcategory of
strict ω-CPOs and strict continuous maps is not. The category of contin-
uous lattices and continuous functions between them is cartesian closed; a
readable proof is in [Scott, 1972], Section 3. Many other categories of do-
mains have been proposed for programming language semantics and many,
but not all, are cartesian closed. More about this is in [Scott, 1982], [Smyth,
1983], [Dybjer, 1986] and [Gunter, 1992].

6.1.16 Example In 2.2.2 we described how to regard a functional pro-
gramming language as a category. If such a language is a cartesian closed
category, then for any types A and B, there is a type [A −→ B] of functions
from A to B. Since that is a type, one can apply programs to data of that
type: that is, functions can be operated on by programs. This means that
functions are on the same level as other data, often described by saying
‘functions are ﬁrst class objects’.

Proposition 6.1.8 puts strong constraints on making functions into ﬁrst
class objects; if you make certain reasonable requirements on your types [A
−→ B], there is essentially only one way to do it.

6.1.17 Example When a deduction system (Section 5.6) is a cartesian
closed category, the constructions giving the exponential turn out to be
familiar rules of logic.

Thus, if A and B are formulas, [A −→ B] is a formula; think of it as A
implies B. Then eval is a proof allowing the deduction of B from A and [A

202

Cartesian closed categories

−→ B]; in other words, it is modus ponens. Given f : C × A −→ B, that is,
given a proof that C and A together prove B, λf is a proof that deduces [A
−→ B] from C. In some logic texts, this is called the rule of detachment.

6.1.18 Exercises

1. Check that the constructions in 6.1.14 make Cat a cartesian closed cat-
egory.

2. In the notation of 6.1.12, show that for any graph G , G × No (the product
in the category of graphs and graph homomorphisms) is essentially the set
of nodes of G , regarded as a graph with no arrows. (Precisely, ﬁnd graph
homomorphisms from the set of nodes of G to G and to No that make the
set of nodes the product.)
3.† This exercise provides a description of the cartesian closed structure on
the category of graphs and graph homomorphisms that is distinct from that
given in 6.1.12. The preceding exercise gives part of the connection between
the two descriptions. For two graphs G and H , deﬁne the exponential [G
−→ H ] in the category of graphs and graph homomorphisms as follows. A
node of [G −→ H ] is a function from G0 to H0 (the nodes of G and H ,
respectively). An arrow consists of three functions f1 : G0 −→ H0, f2 : G0
−→ H0 and f3 : G1 −→ H1 that satisfy the condition that for any arrow n
of G , source(f3(n)) = f1(source(n)) and target(f3(n)) = f2(target(n)). The
source and target of this arrow (f1, f2, f3) are f1 and f2, respectively. Deﬁne
eval : [G −→ H ] × G −→ H by

(cid:189)

eval0(f : G0 −→ H0, n) = f (n)
= f3(a)
eval1((f1, f2, f3), a)

If f : C × G −→ H is a graph homomorphism, deﬁne λf : C −→ [G −→ H ]
to be the homomorphism that takes a node c of C to the function λf (c)
for which λf (c)(g) = f (c, g) for any node g of G , and that takes an arrow
a : c −→ d to the arrow (λf (c), λf (d), fa), where for an arrow u of G , fa(u) =
f (a, u). Show that these constructions provide a cartesian closed structure
on the category of graphs and graph homomorphisms.
4.† Prove Proposition 6.1.8.

6.2 Properties of cartesian closed categories

Many nice properties follow from the assumption that a category is cartesian
closed. Some of them are easy consequences of theorems concerning adjunc-
tions (Chapter 13). Others can be proved using the Yoneda embedding. We
now state some of these basic properties, with some of the proofs outlined.

6.2 Properties of cartesian closed categories

203

Given f : B −→ C in a cartesian closed category, we have the composite

[A −→ B] × A

evalA
B−−−−−→ C

f

−−→ C

Given g : B −→ A we have

[A −→ C] × B

[A −→ C] × g

−−−−−−−−−−−→ [A −→ C] × A

evalA
C−−−−−→ C

These are used in the following proposition.

6.2.1 Proposition Let A be an object of a cartesian closed category C .
There are functors F : C −→ C and G : C op −→ C for which

(i) F (B) = [A −→ B] for an object B, and for an arrow f : B −→ C,

F (f ) = λ(f ◦ evalA

B) : [A −→ B] −→ [A −→ C]

(ii) G(C) = [A −→ C] for an object C, and for an arrow g : B −→ A,

G(g) = λ(evalA

C ◦ [A −→ C] × g) : [A −→ C] −→ [B −→ C]

The value of F at f : B −→ C is normally written

[A −→ f ] : [A −→ B] −→ [A −→ C]

and the value of G at g : B −→ A is normally written

[g −→ C] : [A −→ C] −→ [B −→ C]

These functors are called the internal hom functors of the cartesian closed
category.

Proof. Preservation of the identity is left as an exercise (Exercise 1). We
will prove that F preserves composition. The proof for G is similar. We
must show that, for f : B −→ C and g : C −→ D, [A −→ f ] ◦ [A −→ g] = [A
−→ g ◦ f ]. By Deﬁnition 6.1.3, for any h : X −→ Y , [A −→ h] is the unique
arrow such that

[A −→ X] × A

λ(h ◦ eval) × A

(cid:45)

[A −→ Y ] × A

eval

(cid:63)
X

eval
(cid:63)

Y(cid:45)

h

204

Cartesian closed categories

commutes. But then both squares in the following diagram commute, so the
outer rectangle commutes, so that [A −→ g] ◦ [A −→ f ] = [A −→ g ◦ f ].

[A −→ B]×A

λ(f ◦ eval)×A
(cid:45)

[A −→ C]×A

λ(g ◦ eval)×A
(cid:45)

[A −→ D]×A

eval

(cid:63)
B

eval
(cid:63)

C(cid:45)

g

f

eval
(cid:63)
D(cid:45)

(6.2)

Now that we have Proposition 6.2.1, we can regard both Hom(C × A, B)
and Hom(C, [A −→ B]) as functors of any one of the three variables. Thus
for ﬁxed A and B, there are contravariant functors Hom(− × A, B) and
Hom(−, [A −→ B]) (we don’t need Proposition 6.2.1 to deﬁne these), and
we have already seen in 6.1.7 that these functors are naturally isomorphic.
Because C × A ∼= A × C, A can be treated in the same way as C. For ﬁxed A
and C there are covariant functors Hom(C × A, −) and Hom(C, [A −→ −]),
all deﬁned as composites of functors. The following proposition now follows
from Theorem 13.3.5. It is also not diﬃcult to prove directly.

6.2.2 Proposition The function f (cid:55)→ λf deﬁnes a natural isomorphism

Hom(C × A, −) −→ Hom(C, [A −→ −])

The next proposition follows from Theorem 13.3.7 (see 5.7.2). It is based
on the fact that the deﬁnition of cartesian closed category can be reworded
as stating that the functor [A −→ −] deﬁned by Proposition 6.2.1 is the right
adjoint to the functor A × − that takes an object B to A × B and an arrow
f : B −→ C to idA ×f .

6.2.3 Proposition Any cartesian closed category with ﬁnite sums is a
distributive category.

The proposition below collects the ways in which [A −→ −] behaves like

a hom functor.

6.2.4 Proposition The following isomorphisms hold for any objects A,
B and C in a cartesian closed category. The last two isomorphisms hold
whenever the requisite initial object or sum exists.

(i) [A −→ 1] ∼= 1.

6.2 Properties of cartesian closed categories

205

(ii) [1 −→ A] ∼= A.
(iii) [A × B −→ C] ∼= [A −→ [B −→ C]].
(iv) [A −→ B] × [A −→ C] ∼= [A −→ B × C].
(v) [0 −→ A] ∼= 1.
(vi) [A + B −→ C] ∼= [A −→ C] × [B −→ C].

It is instructive to rewrite these isomorphisms using the notation BA for
the object [A −→ B], and to rewrite them as rules of deduction following the
construction of 6.1.17.

These isomorphisms are ‘natural in all the variables’. This means: ﬁx all
but one variable. Then both sides of the isomorphism are functors in the
remaining variable in a way analogous to what we did for Proposition 6.2.2,
and the isomorphism is a natural isomorphism between those functors. For
example, ﬁxing A and C in item (iv), we have naturally isomorphic functors
[A −→ −] × [A −→ C] and [A −→ (− × C)]. Given f : B −→ B(cid:48), [A −→ f ] is an
arrow as deﬁned in Proposition 6.2.1, and so [A −→ f ] × [A −→ C], meaning
[A −→ f ] × id[A−→C], is the product of two arrows as in 5.2.17. [A −→ (− × C)]
is similarly deﬁned as a composite of functors.

Each of the isomorphisms in Proposition 6.2.4 can be proved by using
fullness of the Yoneda embedding (Theorem 4.5.3). We will prove (iii). For
ﬁxed objects B and C we have functors [− × B −→ C] and [− −→ [B −→ C]]
from C op to C . Then we have the following chain of natural isomorphisms.

Hom(1, [− × B −→ C]) ∼= Hom(− × B, C)

∼= Hom(−, [B −→ C])
∼= Hom(1, [− −→ [B −→ C]])

The second one is that of the isomorphism (6.1), page 198, and the ﬁrst and
third are straightforward. Now Theorem 4.5.3 gives an isomorphism from
[− × B −→ C] to [− −→ [B −→ C]].

The ﬁnal property we consider concerns natural numbers objects (Sec-

tion 5.5).

6.2.5 Proposition Let C be a cartesian closed category with a natural
numbers object. Then the natural numbers object is stable.

Proof. Note that in a cartesian closed category, to construct an arrow B × N
−→ A is equivalent to constructing one N −→ [B −→ A]. Let N be a natural
numbers object and suppose f0 : B −→ A and t : A −→ A. We must ﬁnd a

206

Cartesian closed categories

unique f : B × N −→ A for which

B × succ

(cid:45)

B × N

B × N
(cid:161)(cid:181)

(cid:104)id, zero(cid:105)
(cid:161)

(cid:161)

B

(cid:64)
f0

(cid:64)

(cid:64)(cid:82)

f

(cid:63)
A

f

(cid:63)
A(cid:45)

t

commutes. By deﬁnition of natural numbers object, we know that there is a
unique g : N −→ [B −→ A] for which

zero
(cid:161)

1

(cid:64)
λf0

N

(cid:161)(cid:181)

(cid:161)

g

(cid:64)

(cid:64)(cid:82)
(cid:63)
[B −→ A]

succ

N(cid:45)

g

(cid:63)
[B −→ A]

(cid:45)

[B −→ t]

commutes, where [B −→ t] is the arrow deﬁned in Exercise 5.c. Then by
CCC–3 and the second diagram,

eval ◦ (B × g) ◦ (B × zero) = eval ◦ B × (g ◦ zero) = eval ◦ (B × λf0)

which is f0, so that deﬁning f = eval ◦ B × g will make the triangle in the
ﬁrst diagram commute. (Note that we are using Proposition 6.1.6 here to
evaluate on the ﬁrst coordinate instead of the second.) As for the square,
f ◦ (B × succ) = eval ◦ (B × (g ◦ succ)) = eval ◦ (B × ([B −→ t] ◦ g)) = eval ◦
((B × [B −→ t]) ◦ (B × g)) because the square in the second diagram above
commutes. By Exercise 5.d, this is

eval ◦ (B × λ(t ◦ eval)) ◦ (B × g) = t ◦ eval ◦ (B × g) = t ◦ f

as required. By the uniqueness property of eval, f is unique.

6.2 Properties of cartesian closed categories

207

6.2.6 Exercises

1. Let C be a cartesian closed category with objects A and B. Show that

λ(eval) = id[A−→B] : [A −→ B] −→ [A −→ B]

2. Let g : C(cid:48) −→ C and f : C × A −→ B in a cartesian closed category. Show
that

λ(f ◦ (g × A)) = λf ◦ g : C(cid:48) −→ [A −→ B]

3. Give a direct proof of Proposition 6.2.2.

4. Show that for any cartesian closed category C , the global elements of [A
−→ B] (see 2.7.19) are in one to one correspondence with the elements of
HomC (A, B).

5. This exercise shows how to use the Yoneda embedding to deﬁne the func-
tor [A −→ f ]. It is intended to be done without using any of the results of
this section, since those results depend on Proposition 6.2.1, which is the
aim of this problem to prove.

For any objects A, B, C in a cartesian closed category, let ΛB be the

map

f (cid:55)→ λf : Hom(C × A, B) −→ Hom(C, [A −→ B])

a. Show that ΛB is a bijection.
b. For ﬁxed A and C and h : B −→ B(cid:48), deﬁne the function (cid:98)hC : Hom(C, [A

−→ B]) −→ Hom(C, [A −→ B(cid:48)]) by

(cid:98)hC = ΛB(cid:48) ◦ Hom(C × A, h) ◦ (ΛB)−1

Show that this makes (cid:98)h : Hom(−, [A −→ B]) −→ Hom(−, [A −→ B(cid:48)]) a natural
transformation of contravariant functors to Set.

c. For ﬁxed A and h : B −→ B(cid:48), let [A −→ h] : [A −→ B] −→ [A −→ B(cid:48)]
(we must pretend not to know of the deﬁnition of [A −→ h] in the text)
be the unique arrow induced by Corollary 4.5.4 and the preceding part of
this exercise. Show that Λ is a natural isomorphism from Hom(C × A, −) to
Hom(C, [A −→ −]). (This is an instance of Theorem 13.3.2.)

d. Prove that for any A and h : B −→ B(cid:48),

[A −→ h] = λ(h ◦ eval) : [A −→ B] −→ [A −→ B(cid:48)]

6.† Describe the one to one correspondence of Exercise 4 for the category of
graphs and graph homomorphisms.

208

Cartesian closed categories

6.3 Typed λ-calculus

In order to describe the connection between cartesian closed categories and
typed λ-calculus, we give a brief description of the latter. The material is
essentially adapted from [Lambek and Scott, 1984] and [Lambek and Scott,
1986]. It diﬀers from the latter reference in that we do not suppose the
existence of a (weak) natural numbers object. The brief discussion in [Lam-
bek, 1986] may be helpful as an overview. The standard reference on the
λ-calculus is [Barendregt, 1984], which emphasizes the untyped case.

There is a more general idea of typed λ-calculus in the literature that
includes the idea presented here as one extreme. See [Hindley and Seldin,
1986], pp. 168ﬀ.

6.3.1 Deﬁnition A typed λ-calculus is a formal theory consisting of
types, terms, variables and equations. To each term a, there corresponds
a type A, called the type of a. We will write a ∈ A to indicate that a is a
term of type A. These are subject to the following rules:

TL–1 There is a type 1.
TL–2 If A and B are types, then there are types A × B and [A −→ B].
TL–3 There is a term ∗ of type 1.
TL–4 For each type A, there is a countable set of terms xA

i of type A called

variables of type A.

TL–5 If a and b are terms of type A and B, respectively, there is a term

(a, b) of type A × B.

TL–6 If c is a term of type A × B, there are terms proj1(c) and proj2(c) of

type A and B, respectively.

TL–7 If a is a term of type A and f is a term of type [A −→ B], then there

is a term f ‘a of type B.

TL–8 If x is a variable of type A and φ(x) is a term of type B, then

λx∈Aφ(x) ∈ [A −→ B].

The intended meaning of all the term-forming rules should be clear, with
the possible exception of f ‘a which is to be interpreted as f applied to a.
The notation φ(x) for the term in TL–8 means that φ is a term that might
contain the variable x. We will use the usual mathematical notation for
substitution: if we have called a term φ(x), then φ(a) is the term obtained
by substituting a for every occurrence of x in the term. In the literature on
the λ-calculus, more elaborate notations for substitution are used because
they are necessary in complex calculations.

In much of the literature, the symbol ‘ is omitted; f ‘a would be written

f a.

6.3 Typed λ-calculus

209

6.3.2 Before stating the equations, we need some deﬁnitions. We omit, as
usual, unnecessary subscripts.

If x is a variable, then x is free in the term x. If an occurrence of x is
free in either of the terms a or b, then that occurrence of x is free in (a, b).
If x occurs freely in either f or a, then that occurrence of x is free in f ‘a.
On the other hand, every occurrence of x is not free (and is called bound)
in λxφ(x).

The term a is substitutable for x in φ(x) if no occurrence of a variable
in a becomes bound when every occurrence of x in φ(x) (if any) is replaced
by a. A term is called closed if no variable is free in it.

6.3.3 The equations take the form a =X a(cid:48), where a and a(cid:48) are terms of
the same type and X is a ﬁnite set of variables among which are all variables
occurring freely in either a or a(cid:48).

TL–9 The relation =X is reﬂexive, symmetric and transitive.
TL–10 If a is a term of type 1, then a ={} ∗.
TL–11 If X ⊆ Y , then a =X a(cid:48) implies a =Y a(cid:48).
TL–12 a =X a(cid:48) implies f ‘a =X f ‘a(cid:48).
TL–13 f =X f (cid:48) implies f ‘a =X f (cid:48) ‘a.
TL–14 φ(x) =X∪{x} φ(cid:48)(x) implies λxφ(x) =X λxφ(cid:48)(x).
TL–15 proj1(a, b) =X a; proj2(a, b) =X b, for a ∈ A and b ∈ B.
TL–16 c =X (proj1(c), proj2(c)), for c ∈ A × B.
TL–17 λxφ(x)‘a =X φ(a), if a is substitutable for x in φ(x) and φ(a) is
gotten by replacing every free occurrence of x by a in φ(x).
TL–18 λx∈A(f ‘x) =X f provided x /∈ X (and is thus not free in f ).
TL–19 λx∈Aφ(x) =X λx(cid:48)∈Aφ(x(cid:48)) if x(cid:48) is substitutable for x in φ(x) and x(cid:48) is

not free in φ(x) and vice versa.

It is important to understand that the expression a =X a(cid:48) does not imply
that the terms a and a(cid:48) are equal. Two terms are equal only if they are
identical. The symbol ‘=X ’ may be understood as meaning that in any formal
interpretation of the calculus, the denotation of the two terms must be the
same.

It should be emphasized that these type and term-forming rules and
equations are not exhaustive. There may and generally will be additional
types, terms and equations. It is simply that a typed λ-calculus must have
at least the types, terms and equations described above.

We will usually abbreviate proj1 and proj2 by p1 and p2.

210

Cartesian closed categories

6.3.4 Exercises

1. Let c, c(cid:48) be terms of type A × B. Show that c =X c(cid:48) implies both that
proj1(c) =X proj1(c(cid:48)) and that proj2(c) =X proj2(c(cid:48)).
2. Let a, a(cid:48) be terms of type A and b, b(cid:48) terms of type B. Show that if
a =X a(cid:48) and b =X b(cid:48) then (a, b) =X (a(cid:48), b(cid:48)).

6.4 λ-calculus to category and back

Both of the concepts of typed λ-calculus and cartesian closed category are
adapted to understanding the calculus of functions of several variables, so it
is not surprising that they are equivalent. In this section and the next, we
describe the constructions which give this equivalence.

6.4.1 Deﬁnition of the category Given a typed λ-calculus L , the objects
of the category C(L ) are the types of L . An arrow from an object A to an
object B is an equivalence class of terms of type B with one free variable of
type A (which need not actually occur in the terms).

The equivalence relation is the least reﬂexive, symmetric, transitive rela-
tion induced by saying that two such terms φ(x) and ψ(y) are equivalent if
φ and ψ are both of the same type, x and y are both of the same type, x is
substitutable for y in ψ, and φ(x) ={x} ψ(x), where ψ(x) is obtained from
ψ(y) by substituting x for every occurrence of y.

The reason we need equivalence classes is that any two variables of the
same type must correspond to the same arrow, the identity, of that object
to itself. If λx∈Ax : 1 −→ [A −→ A] is to name the identity arrow of A for any
variable x ∈ A, as is intuitively evident, then the arrow corresponding to a
variable x of type A must be the identity of A.

The equivalence relation also makes two terms containing a variable of
type 1 equivalent (because of TL–10), thus ensuring that 1 will be a terminal
object of the category.

6.4.2
Suppose φ is a term of type B with at most one free variable x of type
A and ψ is a term of type C with at most one free variable y of type B. Note
that by replacing, if necessary, x by a variable that is not bound in ψ, we
can assume that φ is substitutable for y in ψ. We then deﬁne the composite
of the corresponding arrows to be the arrow which is the equivalence class
of the term ψ(φ) obtained by substituting φ for x in ψ.

6.4.3 Proposition The category C(L ) is a cartesian closed category.

6.4 λ-calculus to category and back

211

We will not prove this here. The construction we have given follows Lam-

bek and Scott [1986], who give a proof.

We do not need to say what the cartesian closed structure on C(L ) is
by virtue of Proposition 6.1.8. Nevertheless, the construction is the obvious
one. A × B with proj1 and proj2 is the product of A and B, and [A −→ B] is
the exponential object. If φ(x) determines an arrow f : C × A −→ B, then x
must be a variable of type C × A. Using TL–15, we can substitute (z, y) for
x in φ, getting φ(z, y) where z is of type C and y is of type A. Then λf is
the equivalence class of λzφ(z, y).

Note if z and y actually occur in φ(z, y), then it is not in any equivalence

class, since it has two free variables.

6.4.4 Example We will exhibit a calculation that veriﬁes one of the prop-
erties of a cartesian closed category as an example of how the deﬁnition of
C(L ) works.

Let L be a typed λ-calculus. Deﬁne

Λ : HomC(L )(C × A −→ B) −→ HomC(L )(C −→ [A −→ B])

as follows: for [φ(u)] : C × A −→ B (so that u is a variable of type C × A),
Λ([φ(u)]) = λxφ((z, x)), where z is a variable of type C and x is a variable
of type A. Deﬁne

Γ : HomC(L )(C −→ [A −→ B]) −→ HomC(L )(C × A −→ B)

as follows: for [ψ(z)] : C −→ [A −→ B], Γ([ψ(z)]) = ψ(proj1 u)‘ proj2 u, where
u is a variable of type C × A. Then Λ and Γ are inverse functions.

We will show one direction of the veriﬁcation and leave the other as an
exercise. The following calculation uses TL–18 and the fact that x does not
occur in φ(z) because by deﬁnition of arrow in C(L ), φ(z) contains only
one variable and that is not x.

Λ(Γ(ψ(z))) =
=
=X λxψ(z)‘x
=X ψ(z)

Λ(ψ(proj1 u)‘ proj2 u)
λx(ψ(proj1(z, x))‘ proj2(z, x))

6.4.5 Cartesian closed category to λ-calculus Let C be a cartesian
closed category. We will suppose that it has been equipped with given ﬁnite
products (including, of course, their projections). This means that with each
ﬁnite indexed set of objects {Ai}, i ∈ I, there is a given product cone with
its projections pi :

i∈I Ai −→ Ai.

(cid:81)

212

Cartesian closed categories

The internal language of C is a typed λ-calculus L(C ). We will describe

this λ-calculus by following Deﬁnition 6.3.1.

The types of L(C ) are the objects of C . The types required by TL–1
and TL–2 are the objects 1, A × B and [A −→ B]. We will assume there is
a countable set of variables xA
i of type A for each object A as required by
TL–4. The terms are deﬁned by TL–3 through TL–8, and equality by TL–9
through TL–19.

6.4.6 Theorem Let C be a cartesian closed category with internal lan-
guage L . Then C(L ) is a category equivalent to C .

Lambek and Scott [1986] prove much more than this. They deﬁne what
it means for languages to be equivalent and show that if you start with a
typed λ-calculus, construct the corresponding category, and then construct
the internal language, the language and the original typed λ-calculus are
equivalent. They state this in a more powerful way in the language of ad-
junctions.

6.4.7 Exercises

1. Let A and B be types in a λ-calculus L . Show that in C(L ), eval :
[A −→ B] × A −→ B can be taken to be the equivalence class of the term
(proj1 u)‘(proj2 u), where u is a variable of type [A −→ B] × A.
2. In the notation of Example 6.4.4, prove that Γ(Λ(φ(u))) = φ(u).

6.5 Arrows vs. terms

It may be instructive to compare what a simple function would look like when
deﬁned according to the two kinds of formalism, cartesian closed categories
and the λ-calculus.

6.5.1 Example Consider the function f : N × N −→ N that we would tra-
ditionally deﬁne by the equation

f (x, y) = x2 + 3xy

In the typed λ-calculus, this would appear as:

f = λx∈Nλy∈N x2 + 3xy

which is directly related to the traditional way of doing it. A rendition in a
cartesian closed category is likely to look something like this (in which ∗ is

6.5 Arrows vs. terms

213

multiplication):

N × N

(cid:104)p1, p1, p1, p2, 3(cid:105)

(cid:45)

N × N × N × N × N

· · ·(cid:45)

∗ × ∗ × id

(cid:45)

· · ·

N × N × N

(cid:45)id ×∗

N × N

N(cid:45)+

which appears to be more complicated. However, the categorical formula
could be reformulated as:

p2
1 + 3p1p2

with an obvious semantics.

Thus we see that the only apparent diﬀerence between the two systems,
at least for a simple example like this, is that we write p1 and p2 instead of
x and y. The real diﬀerence is whether one chooses the formula or the com-
putational process. It is worth noting that the categorical notation exposes
clearly that two of the multiplications, at least, can be carried out in parallel.
In fact, by emphasizing the process over the result, the categorical approach
would appear to oﬀer a natural way of exploring questions like that.

6.5.2 The time has come to explain one point that we have blurred up
to now. If a is a term of type A in variables x1 ∈ A1, . . . , xn ∈ An, and b
is a term of type B in variables y1 ∈ B1, . . . , ym ∈ Bm, then we described
(a, b) as a term of type A × B in variables x1, . . . , xn, y1, . . . , ym. A problem
arises with this if there is overlap among the variables. For example, if x is
a variable of type A, then (x, x) is a term of type A × A. But there is only
one free variable in the term. Thus the arrow (cid:104)x, x(cid:105) corresponds to an arrow
A −→ A × A. The arrow in question is the diagonal arrow (cid:104)id, id(cid:105).

The method, using the notation of the preceding paragraph, is to rename
and divide the variables into three classes according to whether they are free
in both a and b, free only in a or free only in b.

Suppose that x1, . . . , xn of type A1, . . . , An respectively are free in a alone,
y1, . . . , ym of type B1, . . . , Bm respectively are free in b alone and z1, . . . , zr
of types C1, . . . , Cr, respectively are free in both. Then

(cid:104)(cid:101)a, (cid:101)b(cid:105) : A1 × · · · × An × B1 × · · · × Bm × C1 × · · · × Cr −→ A × B

is deﬁned as the composite given in (6.3).

214

Cartesian closed categories

A1 × · · · × An × B1 × · · · × Bm × C1 × · · · × Cr

(cid:104)p1, . . . , pn, pn+m+1, . . . , pn+m+r, pn+1, . . . , pn+m, pn+m+1, . . .(cid:105)

(cid:63)
A1 × · · · × An × C1 × · · · × Cr × B1 × · · · × Bm × C1 × · · · × Cr

(6.3)

(cid:104)a, b(cid:105)

(cid:63)
A × B

In other words, a generalized diagonal is used on the repeated entries. It
must be emphasized that this diagonal is used only when the variables are
the same, not merely of the same type. If x and y are distinct free variables
of type A, then the term (x, y) corresponds to an arrow A × A −→ A × A,
namely the identity arrow.

A formal description of a conversion process similar to this in the case of

signatures and equations is described in 7.7.6.

A similar identiﬁcation must be made in the case of function application.

The construction is essentially the same and need not be repeated.

6.5.3 The advantages of cartesian closed categories Of all the ad-
vantages of cartesian closed categories, the most important is that there
being no variables, we never have to worry about any clash of variables.
Consider the rule that says that under certain circumstances,

The categorical interpretation of this rule is simply that for

λx∈Aφ(x) =X λy∈Aφ(y)

f : A1 × · · · × An × A −→ B

then

λf = λf : A1 × · · · × An −→ [A −→ B]
which is identically true. The rule in λ-calculus has to be circumscribed
by conditions. If x and y are two variables of type A and φ(x) = y, then
λxφ(x) (cid:54)= λyφ(y). The left hand side still has y free, while the right hand
side has no free variables. The real problem comes from the use of variables
as what are really only place holders.

Another advantage of the categorical approach, perhaps the most impor-
tant in the long run, is that the composition is built in. This puts the entire
structure of category theory, the machinery of commutative diagrams, etc.
at the service of the enterprise.

6.5.4 Exercise

1. Translate the function f into an arrow to N with domain as shown:

6.6 Fixed points in CCCs

215

a. f (x, y) = x2 + y2, domain N × N.
b. f (x, y, z) = x2 + y2, domain N × N × N.
c. f (x, y) = 5, domain N × N.

6.6 Fixed points in cartesian

closed categories

The main result in this section is that the concept of ω-CPO can be deﬁned
in any cartesian closed category, and that the construction of ﬁxed points
for such objects can be carried out as in Section 2.4.8. This allows cartesian
closed categories to be used as semantic models for functional programming
languages. The assumption that every object in a cartesian closed category
has ﬁxed points is inconsistent with other desirable assumptions on the cat-
egory [Huwig and Poign´e, 1990]. See also [Backhouse et al., 1995].

6.6.1 One of the oft-cited reasons that theoretical computer scientists have
studied untyped λ-calculus is the existence of a ﬁxed point combinator. This
is an element Y with the property that x ‘(Y ‘x) = Y ‘x; that is, Y ‘x is a
ﬁxed point of x. This can hardly make sense in the typed λ-calculus. If,
for example, there is a type of natural numbers, one could not expect the
successor function to have a ﬁxed point. On the other hand, without some
kind of ﬁxed point operator, there is no way of interpreting such a functional
form as (in the notation of [Backus, 1981a])

f = p ⇒ q; H(f )

(6.4)

where H(f ) is some kind of function of f . This may be read, ‘If p Then q
Else H(f )’.

It should be noted that although we use Backus’ notation for convenience,
Backus is interested in actual convergence. Here we are studying the syntactic
question; the ﬁxed point combinator is certainly not guaranteed to give a
terminating function. In the case of the usual ﬁxed point combinator Y , the
ﬁxed point of the identity function is the function (λx ◦ xx)‘(λx ◦ xx), the
typical example of a nonterminating loop.

In order to describe a program (in some pseudo-language) that actually
implements this form, we have to know something about the nature of H.
For example, if H(f ) = g ◦ f ◦ h, then f in equation (6.4) stands for the
inﬁnite program:

216

Cartesian closed categories

If p(x) Then Output q(x)
Else If p ◦ h(x) Then Output g ◦ q ◦ h(x)
Else If p ◦ h ◦ h(x) Then Output g ◦ g ◦ q ◦ h ◦ h(x)
...
Else If p ◦ hn(x) Then Output gn ◦ q ◦ hn(x)
...

Of course, if the condition is never satisﬁed, then the program runs forever.
This can be programmed in closed form as

Proc f (x)
If p(x)
Then Output q(x)
Else Output H(f )(x)
EndIf
EndProc

One way around the dilemma mentioned at the beginning of this section
is to recognize that one does not need all functions to have a ﬁxed point,
only certain ones. Then the question becomes to recognize the ones that do
and show that there are enough of them to provide a description of all loops
you will need. We turn to the ﬁrst point ﬁrst.

Suppose D is a partially ordered object
6.6.2 Partially ordered objects
in a cartesian closed category. This means that on every hom set Hom(A, D),
there is a partial order relation such that for any f : B −→ A and any g, h : A
−→ D, we have that g ≤ h in the hom set Hom(A, D) implies g ◦ f ≤ h ◦ f
in the hom set Hom(B, D). We will similarly say that D is an ω-complete
partial ordered object or ω-CPO object if it is a partial ordered object
and each hom set is an ω-complete partial ordered set, meaning that every
increasing countable chain has a least upper bound.

There is also a notion of an internally ω-complete partial order. Throughout
this section, we understand all references as being to the external notion.

If D and D(cid:48) are ω-complete partial orders, an arrow f : D −→ D(cid:48) is ω-
continuous if, for any object A and any sequence g0 ≤ g1 ≤ . . . of arrows A
−→ D with supremum g, the arrow f ◦ g is the supremum of the sequence
f ◦ g0, f ◦ g1, . . .. Since f ≤ g if and only if the supremum of the sequence
f, g, g, g, . . . is g, it easily follows that an ω-continuous arrow is order-
preserving.

A partially ordered object D is strict if there is an arrow ⊥ : 1 −→ D
such that for any object A and any arrow f : A −→ D, we have ⊥ ◦ (cid:104)(cid:105) ≤ f .
In other words ⊥ is the least element of D.

6.6 Fixed points in CCCs

217

6.6.3 Proposition Suppose D is a strict ω-CPO object and f : D −→ D
is an ω-continuous arrow. Then there is an element ﬁx(f ) : 1 −→ D such
that f ◦ ﬁx(f ) = ﬁx(f ). The element ﬁx(f ) is the least element of D with
this property.

Proof. Since ⊥ is the least element of D, we have that ⊥ ≤ f ◦ ⊥ (the ter-
minal arrow on 1 is id1). Since f is monotone, f (⊥) ≤ f ◦ f (⊥). An obvious
induction allows us to prove that f n(⊥) ≤ f n+1(⊥), where f n denotes the
n-fold composite of f with itself. Thus we get the sequence

⊥ ≤ f (⊥) ≤ f 2(⊥) ≤ · · · ≤ f n(⊥) ≤ f n+1(⊥) ≤ · · ·

We deﬁne ﬁx(f ) to be the least upper bound of this sequence. The fact that
this is ﬁxed is an immediate consequence of the fact that f preserves the
least upper bound of ω-sequences. It is the least ﬁxed point, for if d : 1 −→ D
is another ﬁxed point, one shows by induction beginning from ⊥ ≤ d that
f n(⊥) ≤ d.

6.6.4 Application of ﬁxed point theory to programs It is not im-
mediately evident what the above ﬁxed point theory has to do with the in-
terpretation of programs. Although most familiar data types have a partial
order on them and may even be thought to be ω-complete, most functions do
not preserve the order. For example, squaring does not preserve the natural
order on the set of integers.

It is not the basic data types to which we want to apply the above
constructions. It is rather the arrow types. We want to ﬁnd a ﬁxed point,
not to the successor function, but rather to the function that assigns to
each function f the function p ⇒ q; H(f ) as in Formula (6.4). Moreover, in
thinking about this example, one sees that the appropriate order relation is
the one in which f ≤ g if the domain of deﬁnition of f is included in that
of g and if they agree on that domain. (Compare the discussion in 2.4.8.)
This is how we get the ﬁxed point by successively enlarging the domain. But
once an element gets into the domain of deﬁnition, no further processing is
applied to it. Here is one way of arranging this.

Consider some data type D, that is some object of our category of types.
Forget about any order that may exist on D. Deﬁne a new data type we will
denote D⊥. It is just the object D + {⊥} and the order relation is simply
that ⊥ ≤ d for all d ∈ D and for d (cid:54)= ⊥ and d (cid:54)= d(cid:48) ∈ D, it is never the case
that d ≤ d(cid:48). A CPO with this property (it has a bottom element but no two
other elements are related to each other) is called a ﬂat CPO.

We will suppose that D⊥ is ω-complete. If we make certain assumptions
about our category (which are true in particular in Set) that we will discuss
in Section 9.6, it can be shown that this is so. These questions are addressed

218

Cartesian closed categories

in [Barr, 1990], where the results of this section are ‘internalized’, that is to
say, interpreted in the internal language of the category.

If we do make this assumption, then the data type [A −→ D⊥] is also an
ω-CPO object. In fact an increasing sequence of arrows B −→ [A −→ D⊥] is
equivalent to an increasing sequence of arrows B × A −→ D⊥ and that has a
supremum by assumption. It follows that each continuous endoarrow on [A
−→ D⊥] has a ﬁxed point.

To apply this to Backus’ operator, we have only to show that the func-
tional H is continuous. One interpretation of an arrow A −→ D⊥ is as a
partial arrow from a complemented subobject (see 9.6.2 for the deﬁnition)
of A to D. This is extended to an arrow that takes the value ⊥ on the com-
plementary subobject. An arrow φ : [A −→ D] −→ [A −→ D] preserves order
if and only if whenever g extends f , then φ(g) extends φ(f ). As already
mentioned, the order relation is that of extension of domain. So to apply
Proposition 6.6.3, we have to show that if f is a restriction of g to a smaller
domain, then H(f ) is a restriction of H(g). It must also be shown that if f
is the least upper bound of the increasing sequence

f0 ≤ f1 ≤ · · · ≤ fn ≤ · · ·

then H(f ) is the least upper bound of

H(f0) ≤ H(f1) ≤ · · · ≤ H(fn) ≤ · · ·

Now Backus considers the following possible functional forms for H (it
is a little hard to apply this directly, since for Backus, there is just one data
type, list):

FF–1 H(f ) = r (a constant; r is not constant, H is).
FF–2 H(f ) = fi where f = (cid:104)f1, . . . , fn(cid:105) (here he uses the fact that every-

thing is a list).

FF–3 H(f ) = Γ ◦ (cid:104)E1(f ), . . . , En(f )(cid:105), where E1, . . . , En are (simpler) func-

tional forms and Γ is a function.

All three of these rules generate ω-continuous functions on [D −→ D]
and so are covered by Proposition 6.6.3. Of course, there are many other
possibilities for H. It must be emphasized that Backus is mainly concerned
about convergence and therefore puts other constraints on H, whereas we
are dealing with programs.

7
Finite product sketches

A formal theory in mathematical logic is a speciﬁcation method based on
strings of symbols as the formal structure. A signature, with equations, is
a speciﬁcation based on tuples as the formal structure. A sketch is a speci-
ﬁcation based on graphs as the formal structure. As such, sketches are the
intrinsically categorical way of providing a ﬁnite speciﬁcation of a possibly
inﬁnite mathematical object or class of models.

In Section 4.6 we described a weak form of sketch, linear sketches, to il-
lustrate the constructions involved. In this chapter we generalize the notion
of linear sketch to allow operations with more than one argument. These
are called FP (ﬁnite product) sketches and are deﬁned in Section 7.1. The
example in Section 7.2 shows the connection with signatures. A notation
resembling the notation for signatures and equations is developed in Sec-
tion 7.3, but this notation is intended to be informal. The formal object is
the sketch, not the notation. The connection between FP sketches and the
method of signatures and equations is made more explicit in Section 7.7
(which, by the way, is not needed in the rest of the book).

The semantics for a sketch are given by certain graph homomorphisms.
The nature of FP sketches is such that models can be taken to be in an
arbitrary category with ﬁnite products. We describe this in Section 7.4.

Each FP sketch generates an FP theory (Section 7.5) which is a category
with ﬁnite products. A model of an FP sketch in a category that has ﬁnite
products is a functor that preserves ﬁnite products from the theory to the
category. The theory is analogous to the formal language of mathematical
logic, and the sketch to the recursive rules which deﬁne the language.

Besides the functorial semantics described above, an FP sketch has an
initial algebra semantics which is described in Section 7.6. We also discuss the
construction of free algebras for an FP sketch; the free monoid construction
is a special case of this.

The concept of sketch is due to Charles Ehresmann and has been highly
developed by his students in France. Their formalism is diﬀerent from ours
and is described in [Bastiani and Ehresmann, 1972] and, using more up-to-
date notation, by Coppey and Lair [1984, 1988]. Guitart and Lair [1980]
describe the connections with other formalisms. Much of their discussion is
updated in [Ad´amek and Rosiˇcky, 1994]. Bibliographies may be found in
[Permvall, 1991] and [Wells, 1993].

219

220

Finite product sketches

This chapter and Chapters 8 and 10 form a sequence that introduces
successively more powerful forms of sketches. The concepts in this sequence
are not used in the rest of the book, except that Section 9.7 requires the
concept of FP sketch and Section 15.7 requires the sketch for categories
given in 10.1.5.

7.1 Finite product sketches

We ﬁrst deﬁne discrete cones, which are used to specify that an object of a
sketch is a product.

7.1.1 A ﬁnite discrete cone in the graph G consists of a ﬁnite discrete
graph I , a graph homomorphism L : I −→ G , a node n of G and a collection
of arrows pi : n −→ Li, one for each node i ∈ I . The node n is called the
vertex of the cone and the diagram L the base of the cone. Since I is
discrete, the base of the cone is an indexed family of nodes. In particular it
is possible to have Li = Lj for i (cid:54)= j.

We will often use other labels for the nodes and arrows. Thus in the

discrete cone

Li

v

(cid:161)

(cid:64)

(cid:64)

t
(cid:64)
(cid:64)(cid:82)

Lj

(7.1)

(cid:161)

s
(cid:161)

(cid:161)(cid:170)

v is the vertex, s is the arrow pi and t is the arrow pj. Note that if Li and
Lj are the same object but i (cid:54)= j, s and t are not required to be the same.

We could have deﬁned cone in a graph the way we deﬁned cone in a category
in 5.1.4 and in Section 5.3, in particular saying that the base is indexed by a
set instead of saying it is a graph homomorphism from a discrete graph (that
is, a discrete diagram). When we study general limits we will introduce cones
with arrows between the nodes of the base, so that the base is itself a diagram.
Then, the construction here will be seen as a special case – the discrete case.
Hence the name ‘discrete cone’.

7.1.2 Deﬁnition A cone in a category is called a product cone if it is a
product diagram in the category.

7.1.3 Deﬁnition A ﬁnite product sketch or FP sketch S is a triple
(G , D, L ) where G is a ﬁnite graph, D a ﬁnite set of ﬁnite diagrams in G
and L a ﬁnite set of ﬁnite discrete cones in G .

7.1 Finite product sketches

221

7.1.4 Deﬁnition Let S = (G , D, L ) be an FP sketch and C be a cat-
egory. By a model of S in C , or an S -algebra in C , we mean a model
M of the linear sketch (G , D) in C that has the additional property that
for any cone L : I −→ G in L , the composite M ◦ L is a product cone. For
example if the cone looks like

v

(cid:161)

s
(cid:161)
(cid:161)(cid:170)

(cid:64)

t
(cid:64)
(cid:64)(cid:82)

Lj

Li

then our condition requires that

M v

(cid:161)

(cid:64)

M s
(cid:161)(cid:170)

(cid:161)

M Li

(cid:64)

M t
(cid:64)(cid:82)

M Lj

be a product cone in C . If the cone is

v

meaning that the base is empty, then the cone

M v

(7.2)

(7.3)

(7.4)

(7.5)

should also be a product cone, which means precisely that M v should be a
terminal object of C .

When we refer to a model of a sketch without mentioning the category

C , we mean a model in Set.

7.1.5 A simple example of an FP sketch In 4.7.7, we described a
linear sketch with constants for the natural numbers. Here we do the same
thing with an FP sketch. The sketch has two nodes we will name 1 and n.
There is just one cone, namely the cone with 1 as vertex and empty base.

222

Finite product sketches

As we mentioned above, the result is that in any model M , M (1) must be
the terminal object of the value category. The graph has just two arrows,

zero : 1 −→ n

and

succ : n −→ n

The sketch has no diagrams.

Since M (1) is terminal in any model, in the category of sets M (1) is a
one-element set, so that M (zero) is a function from a one-element set into
M (n), i.e. an element of M (n). Note that this observation is independent of
which one-element set M (1) actually is. In an arbitrary category, M (1) is
terminal, and M (zero) is then a global element or constant (see 2.7.19).

M (succ) is any arrow from M (n) to M (n), so that a model of this sketch
in an arbitrary category is an object together with an endoarrow and a
constant. Even in the category of sets, there are many models of this sketch
that are not the natural numbers. How to pick out those that are will be
explored in Section 7.6.

7.1.6 Inﬁnite lists Let S be the sketch with three nodes, 1, d and l,
arrows a, b : 1 −→ d, head : l −→ d and tail : l −→ l, no diagrams, and two
cones, one empty with 1 at the vertex and the other C given by

l

(cid:161)

(cid:64)

(cid:161)

head
(cid:161)
(cid:161)(cid:170)

d

(cid:64)

tail
(cid:64)
(cid:64)(cid:82)

l

One model of this sketch is the model M with M (l) the set of all inﬁnite se-
quences of a’s and b’s. M (head) gives the ﬁrst entry of a sequence and M (tail)
gives the sequence obtained by deleting the ﬁrst entry of the sequence.

If you try to deﬁne a model M of this sketch in which M (l) is the set
of ﬁnite lists of a’s and b’s and head and tail have their usual meaning, you
will run into trouble eventually. The reason is that if a list is ﬁnite, then
repeated applications of M (tail) to it will eventually give the empty list, but
the empty list has no head, so there is no obvious way to allow it to be in
M (l). Various ways of handling this type of error have been suggested in the
literature, for example [Goguen, 1978] and [Wells and Barr, 1988] (the latter
is described in Section 8.1).

7.1.7 We can introduce addition into the sketch in 7.1.5 by adding a binary
operation, using our new ability to specify that an object be a cartesian

product. We need an object n × n and a diagram

7.1 Finite product sketches

223

n × n
(cid:64)
(cid:161)

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

n

(cid:64)

p2
(cid:64)

(cid:64)(cid:82)

(7.6)

n

The notation n × n indicates our intention that the node become a product
in a model. It cannot itself be a product, since it is a node in a graph, not
an object of a category and products are deﬁned only for categories.

A systematic method for describing this situation is to use the word
‘formal’: the diagram (7.6) is a formal product diagram, meaning that
its value in a model must be a product diagram. Similarly, the node v in
Diagram (7.4) is a formal terminal object.

We will also need new arrows:

z : n −→ n
idn : n −→ n
(cid:104)idn, z(cid:105) : n −→ n × n
+ : n × n −→ n

idn × succ : n × n −→ n × n
Deﬁnition 7.1.4 will force M (n × n) to be isomorphic to M (n) × M (n) for
a model M . To simplify the discussion, we assume M (n × n) is actually
identical to M (n) × M (n). In 7.2.7 and 7.2.8 below we will show how this
assumption is avoided.

The following diagrams ensure that this operation will satisfy the induc-

tive deﬁnition of addition for integers:

n

(cid:64)

(cid:64)

(cid:64)(cid:82)

n(cid:45)
(cid:161)(cid:181)
zero

(cid:161)

(cid:161)

z

1

(a)

n

(cid:161)

z
(cid:161)

(cid:161)

(cid:161)(cid:170)
(cid:190)

p1

(cid:190)p1

n

n × n

n

(cid:161)

(cid:64)

(cid:161)

(cid:64)

(cid:64)

(cid:104)idn, z(cid:105)

p2

(cid:63)
n × n

(b)
n(cid:45)p2

idn
(cid:64)

(cid:64)

(cid:64)(cid:82)
n(cid:45)

idn

idn

(cid:82)

n

(c)

(cid:63)
n

(cid:190)

p1

succ

(cid:63)

n(cid:45)

p2

idn × succ
(cid:63)
n × n

(d)

224

Finite product sketches

(cid:104)idn, z(cid:105)

(cid:45)

n × n

n

n × n

n(cid:45)+

(cid:64)

(cid:64)
idn

(cid:64)

(cid:64)

(cid:64)

(cid:64)(cid:82)

(e)

+

(cid:63)
n

idn × succ

succ

(cid:63)
n × n

(cid:63)

n(cid:45)

+
(f)

In a model M , the commutativity of (a) forces the arrow M (z) to be the
constant map which takes any element of M (n) to the element determined by
zero. The commutativity of (b) forces the center arrow to go to the product
suggested by its name: it forces

M (cid:104)idn, z(cid:105) = (cid:104)M (idn), M (z)(cid:105) = (cid:104)idM (n), M (z)(cid:105)

The commutativity of (c) forces

and that of (d) forces

M (idn) = idM (n)

M (idn × succ) = idM (n) ×M (succ)

The last two force the inductive deﬁnition of addition to be true in a model:
k + M (zero) = k and k + M (succ)(m) = M (succ)(k + m).

7.1.8 A model of the resulting FP sketch that takes n to the set of natural
numbers, succ to the successor function and zero to 0 is forced by the dia-
grams to take + to the usual addition function, simply because the inductive
deﬁnition determines addition uniquely. However, there is no way, using an
FP sketch, to force the model to take n to the natural numbers in the ﬁrst
place. We will look at this again when we consider FD sketches.

7.1.9 Exercises

1. Prove the claim concerning + made in 7.1.8.

2. Let S be a sketch with one node a and two arrows f, g : a −→ a. It has
one cone

a

(cid:161)

f
(cid:161)(cid:170)

(cid:161)

a

g(cid:64)
(cid:64)
(cid:64)(cid:82)

a

Show that in any model M in Set, M (a) is either empty or is a singleton
set or is inﬁnite, and that the sketch does indeed have an inﬁnite model.

3. Explain how to adjoin a multiplication to Example 7.1.7 so that it be-
comes the usual multiplication when the model is actually N.

7.2 The sketch for semigroups

225

7.2 The sketch for semigroups

We now develop a substantial example of an FP sketch of a type of math-
ematical structure, namely the sketch for semigroups. It exhibits many of
the issues and subtleties concerning presentation of structures by sketches.
The presentation is quite lengthy; later we introduce a notation which makes
such presentations shorter and easier to read. In 7.3.2, we describe how to
extend this sketch to a sketch for monoids.

7.2.1 We deﬁne an FP sketch S = (G , D, L ). The graph G has three
nodes we will give the names s, s × s and s × s × s. As in 7.1.7, these
three nodes are not, indeed cannot be, products (which are deﬁned only in
categories). They are formal products, as the names suggest.

The arrows in the graph are:

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

s

s × s

(cid:161)

(cid:64)

c

(cid:63)
s

(a)

(cid:64)

p2
(cid:64)

(cid:64)(cid:82)

p1
(cid:161)

(cid:161)(cid:170)

s

s

s × s × s
(cid:64)
(cid:161)

(cid:161)

p2

(cid:64)

(cid:63)
s

(b)

p3
(cid:64)

(cid:64)(cid:82)

s

s × s × s
(cid:64)
(cid:161)

s × s × s
(cid:64)
(cid:161)

(cid:161)

(cid:104)p1, p2(cid:105)
(cid:161)
(cid:161)(cid:170)

s × s

(cid:64)

(cid:104)p2, p3(cid:105)
(cid:64)
(cid:64)(cid:82)

s × s

(cid:161)

s × c
(cid:161)

(cid:161)(cid:170)

s × s

(cid:64)

c × s
(cid:64)
(cid:64)(cid:82)
s × s(cid:45)

(c)

(d)

We have given the graph in four pictures, but it is just one graph with
three nodes and ten arrows. Note that there are two arrows labeled p1 and
two labeled p2. This is overloaded terminology, used by long convention.
For i = 1, 2, the two arrows named pi are necessarily diﬀerent because their
domains and codomains are diﬀerent.

226

Finite product sketches

7.2.2 Before giving the details of the diagrams and cones, we pause to
explain the intent of this example. Up till now, we have described a graph.
What is a model of this graph in the category Set? We need sets we call S =
M (s), S2 = M (s × s) and S3 = M (s × s × s). For the moment, the exponents
are simply superscripts. In addition we require functions M (pi) : S2 −→ S,
i = 1, 2, M (pi) : S3 −→ S, i = 1, 2, 3, M (c) : S2 −→ S and M (s × c) and
M (c×s) from S3 to S2. So far, this is nothing familiar, but if we now suppose,
as suggested by the notation, that S2 and S3 are actually the cartesian
square and cube of S and if we make certain subsidiary assumptions given
by diagrams to be described later, these data cause S to be a semigroup
whose multiplication map is given by M (c) : S × S −→ S.

The subsidiary hypotheses are

(i) The various M (pi) are indeed the projections suggested by the nota-

tion.

(ii) M ((cid:104)p1, p2(cid:105)) = (cid:104)M (p1), M (p2)(cid:105) and similarly for (cid:104)p2, p3(cid:105).
(iii) M (c × s) : S × S × S −→ S × S is the unique function (guaranteed by

the speciﬁcation for products) for which the diagram

S × S × S
(cid:64)

(cid:161)

(cid:161)

(cid:64)
M (c × s) M (p3)

(cid:64)

M (cid:104)p1, p2(cid:105)
(cid:161)

(cid:161)

(cid:161)(cid:170)
S × S
(cid:64)

(cid:64)
M c

(cid:64)

(cid:63)
S × S

(cid:64)

(cid:64)(cid:82)
S(cid:45)

M (p2)

(7.7)

M (p1)

(cid:64)

(cid:64)(cid:82)

(cid:63)
S

commutes. This diagram merely expresses the fact that M (c × s) =
M (c) × idS, which we need to get associativity (in Diagram (d) below).

(iv) A similar diagram expresses the fact that M (s × c) = idS ×M (c).
(v) Finally, if we want a semigroup, we must express the associative law

of the multiplication. This is done by saying that the diagram

S × S × S

M (s × c)

(cid:45)

S × S

M (c × s)

M (c)

(7.8)

(cid:63)
S × S

(cid:63)

S(cid:45)

M (c)

commutes.

7.2 The sketch for semigroups

227

7.2.3 Our task will be to express these requirements in our sketch. This is
done as follows. We let D consist of the following diagrams:

(cid:161)(cid:161)(cid:170)
(cid:190)

s

(cid:64)(cid:64)(cid:82)
s(cid:45)

s × s × s
(cid:64)
(cid:161)
(cid:104)p1, p2(cid:105)

(cid:161)

p1

(cid:161)

(cid:64)

p2

(cid:64)

p1

(cid:63)
s × s

(a)

p2

s × s × s
(cid:64)
(cid:161)

(cid:104)p1, p2(cid:105)

(cid:161)

(cid:161)(cid:161)(cid:170)

s × s

(cid:161)

c × s

(cid:63)
s × s

(cid:64)
(cid:64)
c

(cid:64)

p1

(cid:64)(cid:64)(cid:82)

(cid:63)
s

(c)

(cid:161)

s × s × s
(cid:64)
(cid:161)
(cid:104)p2, p3(cid:105)
(cid:63)
s × s(cid:45)

p2
(cid:161)

(cid:161)(cid:170)

p1

s

(cid:64)

p3
(cid:64)

(cid:64)(cid:82)
s(cid:45)

p2

(b)

s × s × s
(cid:161)
(cid:64)

(cid:161)

p1

(cid:161)

s × c

(cid:63)
s × s

p2

(cid:64)

(cid:64)

(cid:104)p2, p3(cid:105)

(cid:64)(cid:64)(cid:82)
(cid:45)

s × s

(cid:161)
(cid:161)
c

(cid:161)

(cid:161)(cid:170)

(cid:63)
s

(cid:64)

p3

(cid:64)

p2

(cid:64)(cid:64)(cid:82)
s(cid:45)

(cid:161)(cid:161)(cid:170)
(cid:190)

s

p1

(d)

s × s × s

s × s(cid:45)s × c

c × s

(cid:63)
s × s

c

(cid:63)

s(cid:45)

c

(e)

These ﬁve diagrams have (e) as their main statement; (c) and (d) are needed
to deﬁne arrows which occur in (e), and (a) and (b) are needed to deﬁne
arrows which occur in (c) and (d). This construction is reminiscent of the way
you construct progressively higher level procedures in Pascal culminating in
the procedure which actually does what you want.

228

Finite product sketches

7.2.4 The set L of cones consists of the following:

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

s

s × s

(cid:161)

(cid:64)

(a)

(cid:64)

p2
(cid:64)

(cid:64)(cid:82)

s

p1
(cid:161)

(cid:161)(cid:170)

s

s × s × s
(cid:64)
(cid:161)

(cid:161)

p2

(cid:64)

(cid:63)
s

(b)

p3
(cid:64)

(cid:64)(cid:82)

s

(7.9)

Then we say that the model M of S is a model of the sketch if all the
diagrams in D become commutative diagrams when M is applied and if all
the cones in L become product cones. In particular, up to a technicality
to be discussed below, diagram (c) in D becomes (7.7), and diagram (e)
becomes (7.8).

7.2.5 Models in Set A model of this FP sketch in Set is essentially a
semigroup. We will now spell out the precise relationship (which is fairly
subtle) between a model of the sketch for semigroups and the usual way of
describing a semigroup: a semigroup is a set S with an associative binary
operation m : S × S −→ S. We will discuss models in an arbitrary category
in more detail in Section 7.4.4.

7.2.6 Every semigroup determines a model of S in Set Let S be
a semigroup with operation m : S × S −→ S. We construct a model M of the
sketch S of semigroups developed above. We take M (s) = S, M (s × s) =
S × S, and M (s × s × s) = S × S × S. For the arrows of G , we deﬁne the
following arrows. The diagram numbers refer to 7.2.3.

(i) M (c) = m.
(ii) M (pi) = pi : S × S −→ S, for i = 1, 2.
(iii) M (pi) = pi : S × S × S −→ S, for i = 1, 2, 3.
(iv) M (cid:104)p1, p2(cid:105) in Diagram 7.2.3(a) is the function which takes (r, t, u) to
(r, t). This function, of course, is normally denoted (cid:104)p1, p2(cid:105), which is
why the arrow in Diagram 7.2.3(a) above is so labeled.

(v) M (cid:104)p2, p3(cid:105) in Diagram 7.2.3(b) to be the function which takes (r, t, u)

to (t, u).

(vi) M (c × s) in Diagram 7.2.3(c) to be the function m × idS which takes

(r, t, u) to (rt, u).

(vii) M (s × c) in Diagram 7.2.3(d) to be the function idS ×m which takes

(r, t, u) to (r, tu), i.e., (r, m(t, u)).

7.2 The sketch for semigroups

229

Since we have required the arrows labeled pi to be actual product pro-
jections, the two cones in the sketch both become product cones in Set.
Similarly, all ﬁve diagrams in 7.2.3 become commutative diagrams; in par-
ticular, Diagram 7.2.3(e) is just the associative law.

As an example of how one shows the diagrams become commutative,
we will check the commutativity of the right half of Diagram 7.2.3(d). This
translates into proving that

M (p2) ◦ M (s × c)(r, t, u) = M (c) ◦ M (cid:104)p2, p3(cid:105)(r, t, u)

for any triple (r, t, u) of elements of S. Applying the deﬁnition of M on
arrows, this requires that p2(r, tu) = M (c)(t, u), that is, that tu = tu since
M (c) = m, the multiplication of the semigroup. The other veriﬁcations are
similar.

7.2.7 Every model of S in Set determines a semigroup If M is
a model of S in Set, then M (c) : M (s2) −→ M (s) determines a binary
operation on M (s), since M (s2), with the functions M (pi) : M (s2) −→ M (s)
for i = 1, 2, is a product M (s) × M (s) in Set. (See the discussion in 5.2.6.)
Since M takes every diagram of S to a commutative diagram in Set,
Diagram (7.8) commutes, and because diagrams (c) and (d) of 7.2.3 com-
mute, we have that the following diagram commutes. Here we write S ×S and
S × S × S for M (s × s) and M (s × s × s), respectively. Because of the unique
isomorphisms given by Theorem 5.2.2, it does not matter which particular
product is used since if the diagram commutes with one, it will commute
with any other one (see 5.2.1 and Proposition 5.2.18).

S × S × S

M (s) × M (c)

(cid:45)

S × S

M (c) × M (s)

M (c)

(7.10)

(cid:63)
S × S

(cid:63)

S(cid:45)

M (c)

But this is precisely the associativity of the multiplication.

7.2.8 Subtleties The preceding constructions exhibit the subtle relation-
ship between the usual informal method of describing a mathematical struc-
ture and a model of a sketch of the structure.

In the ﬁrst place, models do not have to take vertices of cones to canonical
products; thus M (s × s) need not be the same as M (s) × M (s). This was just
discussed in connection with Diagram (7.10). In any case, one can regard the
map M (c) : M (s × s) −→ M (s) as a binary operation on M (s) deﬁned on a

230

Finite product sketches

coded form of the cartesian product M (s) × M (s), as discussed in 5.2.1. The
unique isomorphism between M (s × s) and the actual set of ordered pairs
guarantees that the binary operation is uniquely deﬁned on M (s) × M (s).
A deeper diﬀerence is that there are no distinguished nodes or operations
in a sketch. The graph of the sketch for semigroups, for example, has three
nodes, no one singled out, whereas in the usual deﬁnition of semigroup, the
underlying set S (corresponding to M (s) in a model of the sketch) is singled
out and other things are deﬁned in terms of it. Similarly, in the graph there
are various arrows; c is just one of them.

The sketch approach requires you to construct everything you need ex-
plicitly from a few basic constants and operations. Consider the traditional
deﬁnition of semigroup. You are given a set S and a binary operation on
S. The set S × S is regarded as there for you to use in giving the binary
operation. Similarly, when you state the associative law you use S × S × S
(or more traditionally, triples of variables from S) without comment: you
already have it available.

By contrast, when you use a sketch to describe semigroups, you have to
give explicitly everything you use and every property it has. Nothing exists
until you construct it, as in lazy evaluation, where a datum is not constructed
until it is needed. Thus to deﬁne the binary operation, you need a node to
become the cartesian product of M (s) with itself, so you put it in the graph
and you put in a cone making it a cartesian product. To state the associative
law, you need M (c) × M (idM (s)), so you have to put in the arrow c × s and
Diagram 7.2.3(c); to construct that, you need (cid:104)p1, p2(cid:105) and Diagram 7.2.3(a);
and so on.

The result looks much more complicated than the usual way of deﬁning
a semigroup, even if you use the elaborate formal notation of signatures and
equations. That is because everything you need is constructed from scratch.
The sketch is the formal object corresponding to the informal speciﬁcation
for semigroups, and it is appropriate for the formal object to expose all
the girders and braces, so to speak. Sketches are not designed as notation,
but as a mathematical structure embodying the formal syntax. We introduce
a usable informal notation in Section 7.3 below which allows the eﬃcient
description of sketches. The fact that the girders and braces are exposed is
what allows you to deﬁne models in arbitrary categories. They would also
be necessary ingredients of a computer model of a sketch.

The derived sorts and operations not needed in a sketch are still there
potentially, just as they are for signatures. Where they exist is in the theory
of the sketch, discussed in Section 7.5 below.

7.3 Notation for FP sketches

231

7.2.9 Exercises

1. Let S be a sketch that has two nodes s and s × s and three arrows
p, q, c : s × s −→ s. It has one diagram

and one cone

s × s

c
−−→−−→
p

s

s × s

p (cid:161)
(cid:161)
(cid:161)(cid:170)

q(cid:64)
(cid:64)
(cid:64)(cid:82)

s

s

Show that in a model M in Set, M (c) is an associative binary operation
on M (s). (Nevertheless, most semigroups are not models of this sketch.) We
look at this sketch again in Exercise 1 of Section 7.4.

2. A semigroup S is idempotent if for every x ∈ S, x · x = x. Add arrows
and diagrams to the sketch for semigroups that force the models to be idem-
potent semigroups.
3.† What modiﬁcations to the sketch for semigroups would have to be made
so that a model is a real (or complex) vector space? (This sketch is not ﬁnite:
you will need one unary operation of scalar multiplication for each scalar.)

7.3 Notation for FP sketches

The reader will see that the cones and most of the diagrams used in the
sketch for semigroups are required to specify that nodes are products of
other nodes and that certain arrows into products are speciﬁed by their
projections. Accordingly, we will adopt notation that will allow us in most
cases to avoid writing down the cones and most of the diagrams. Although
these are just notational conventions, they are extremely important for they
are what make the use of sketches feasible.

In later sections, we will increase the expressive power of sketches in
various ways, and extend the list of notations which begins below to cover
those cases.

7.3.1 These conventions are as follows:

N–1 It is understood that in all the conventions below, an is a shorthand

for a × a × · · · × a, with n copies of the node a.

232

Finite product sketches

N–2 If the sketch has nodes called a1, a2, . . . , an and a1 × a2 × · · · × an, then

it is understood that there is a cone

a1 × a2 × · · · × an

(cid:161)

(cid:161)

pi

(cid:64)

p1
(cid:161)

(cid:161)(cid:170)

a1

· · ·

(cid:64)

pn
(cid:64)

(cid:64)(cid:82)

· · ·

an

(cid:63)
ai

N–3 A node labeled 1 is assumed to imply the existence of a cone whose

vertex is that node and whose base is the empty diagram.

N–4 If an arrow has the form

(cid:104)f1, f2, . . . , fn(cid:105) : a −→ b1 × b2 × · · · × bn

where fi : a −→ bi, i = 1, . . . , n, then there are assumed to be diagrams

a

(cid:161)

(cid:64)

(cid:104)f1, f2, . . . , fn(cid:105)
(cid:161)
(cid:161)(cid:170)

(cid:161)

b1 × b2 × · · · × bn

(cid:64)

fi
(cid:64)
(cid:64)(cid:82)
(cid:45)

pi

bi

for i = 1, . . . , n.

N–5 If an arrow has the form

f1 × f2 × · · · × fn : a1 × a2 × . . . × an −→ b1 × b2 × · · · × bn

where fi : ai −→ bi, i = 1, . . . , n then there are assumed to be diagrams

a1 × a2 × · · · × an

ai(cid:45)pi

f1 × f2 × · · · × fn

fi

(cid:63)
b1 × b2 × · · · × bn

(cid:45)

(cid:63)
bi

pi

for i = 1, . . . , n.
N–6 A diagram of the form
(cid:45)s2

k1

· · ·(cid:45)

kn−2(cid:45)

kn−1(cid:45)sn−1

k2

s1 (cid:161)(cid:161)(cid:181)
i
t1 (cid:64)(cid:64)(cid:82)

l1

t2

(cid:45)

l2

· · ·(cid:45)

lm−2(cid:45)

tm−1

sn(cid:64)(cid:64)(cid:82)
j
tm(cid:161)(cid:161)(cid:181)

lm−1(cid:45)

(7.11)

7.3 Notation for FP sketches

233

may, if convenient, be speciﬁed by the notation

sn ◦ sn−1 ◦ · · · ◦ s1 = tm ◦ tm−1 ◦ · · · ◦ t1

The reader should note that this is only a formal equation; it has no
meaning except as part of our convention since there is no composition
of arrows in graphs.

The result of these notational conventions is that the sketch for semi-

groups may be speciﬁed by the graph as in 7.2.1, plus the single diagram

s × s × s

s × s(cid:45)s × c

c × s

(cid:63)
s × s

c

(cid:63)

s(cid:45)

c

Equivalently, we may specify an equation

c ◦ (s × c) = c ◦ (c × s)

which is the usual form of the associative law.

7.3.2 There is at least one case in which the proper interpretation of some
of these conventions may not be transparent; namely when n = 0. For ex-
ample, we can extend the sketch for semigroups to become a sketch for mon-
oids by adjoining a unary operation e : 1 −→ s and the following diagrams
expressing the identities ex = xe = x:

s

s × s(cid:45)(cid:104)s, e(cid:104)(cid:105)(cid:105)
(cid:64)
(cid:64)
i

c

(cid:64)

(cid:64)(cid:82)

(cid:63)
s

s

s × s(cid:45)(cid:104)e(cid:104)0(cid:105), s(cid:105)
(cid:64)
(cid:64)
i

c

(cid:64)

(cid:64)(cid:82)

(cid:63)
s

i

(cid:82)

s

The rightmost diagram is seen to be an example of Diagram (7.11) with
i = j = s, m = 0, n = 1 and s1 = id. We generally use one more notational
convention to express this:

N–7 A commutative diagram of the form of Diagram (7.11) with m = 0 may,

if convenient, be speciﬁed by the notation

sn ◦ sn−1 ◦ · · · ◦ s1 = idi

234

Finite product sketches

7.4 Arrows between models of FP sketches

If M and M (cid:48) are two models of an FP sketch S in a category C , a homo-
morphism α : M −→ M (cid:48) is deﬁned to be a natural transformation between
M −→ M (cid:48), considered as models of the underlying graphs. Just as in 4.6.4,
all the models of an FP sketch in C form a category Mod(S , C ) which
is a full subcategory of the category of all graph homomorphisms from the
graph of S to C . We will discuss the details for models in Set ﬁrst and then
consider models in an arbitrary category in 7.4.4.

7.4.1 Let N be the model of the sketch in 7.1.5 for which N (1) = {∗},
N (n) = N (the set of natural numbers), N (succ) is the function taking n to
n + 1, and N (zero) is the function picking out 0. Let M be the model which
is the same for 1, for which M (n) = {0, 1, 2, 3}, M (zero) is 0, and M (succ)
takes 0 to 1, 1 to 2, and both 2 and 3 to 3. Then there is a homomorphism
of models α : N −→ M in which αn : N (n) −→ M (n) takes 0, 1 and 2 to
themselves and all other natural numbers to 3. What α1 does is forced.

The only nontrivial requirement forced by the deﬁnition of homomorph-

ism is that for all natural numbers k,

M (succ)[αn(k)] = αn[N (succ)(k)]

which you should check.

7.4.2 In the case of sketches which specify mathematical structures, these
homomorphisms are in most cases essentially the same as homomorphisms
as usually deﬁned. For example, we have the following proposition.

7.4.3 Proposition Let M and N be two models of the sketch S for semi-
groups in Set (so that M (s) and N (s) are semigroups, see 7.2.7). Then if
α : M −→ N is a natural transformation, the component αs : M (s) −→ N (s)
is a semigroup homomorphism (see 2.5.1). Conversely, a semigroup homo-
morphism h : M (s) −→ N (s) induces a unique natural transformation α : M
−→ N for which αs = h.

Proof. For convenience, we will suppose that M and N take the cones in the
diagram to canonical cones, but this can be avoided as described in 7.2.7.
If M and N are models a natural transformation α between the sketches is
given by three functions α(s) : M (s) −→ N (s), α(s×s) : M (s×s) −→ N (s×s)
and α(s × s × s) : M (s × s × s) −→ N (s × s × s). There is a commutativity

condition imposed for each arrow of the graph. The crucial one says that

7.4 Arrows between models

235

M (s) × M (s)

α(s × s)

(cid:45)

N (s) × N (s)

M (c)

(cid:63)
M (s)

N (c)

(cid:63)
N (s)

(cid:45)

α(s)

commutes. We can now see that the commutativity of the diagram above is
exactly the deﬁnition of semigroup homomorphism: write h for α(s) and, for
(x, y) ∈ M (s) × M (s), write xy for M (c)(x, y). Then going south and east in
the diagram gives h(xy) and going east and south gives N (c)[h × h](x, y) =
N (c)(h(x), h(y)) = h(x) · h(y).

As for the converse, what must be shown is that a natural transformation
α : M −→ N with a homomorphism h as component at s must have h × h
and h × h × h as components at s × s and s × s × s respectively. Let l be the
component of α at s × s. Then l must make the following diagram commute
simply because α is a natural transformation.

M (s × s)
(cid:64)
(cid:161)

(cid:161)

M (p1)
(cid:161)
(cid:161)(cid:170)

M (s)

l

(cid:64)

M (p2)
(cid:64)
(cid:64)(cid:82)

M (s)

(cid:63)
N (s × s)
(cid:161)
(cid:64)

h

N (p1)
(cid:161)

h

N (p2)
(cid:64)

(cid:161)

(cid:161)(cid:170)

(cid:63)
N (s)

(cid:64)

(cid:64)(cid:82)

(cid:63)
N (s)

But each M (pi) and N (pi) is a product projection in Set because models
must take cones in L to product cones. It then follows from 5.2.17 that l is
h × h. The proof for s × s × s is similar.

7.4.4 Models of a sketch in an arbitrary category We have deﬁned
the concept of model of an FP sketch S in any category. Here, we will
explain in more detail what a model of the sketch for monoids (see Section 7.2
and 7.3.2) in an arbitrary category C must look like.

Let M be such a model, and let C = M (s), mult = M (c) and unit = M (e)
(e is deﬁned in 7.3.2). It follows that the structure in C corresponding to M

236

Finite product sketches

consists of an object C of C together with an arrow mult : C × C −→ C of
C and an arrow unit : 1 −→ C such that the following diagrams commute:

C × C × C

C × mult
(cid:45)

C × C

C

C × unit
(cid:45)

C × C

(cid:190)unit ×C

C

mult ×C

mult

(cid:63)
C × C

(cid:63)

C(cid:45)

mult

(cid:64)

(cid:64)
=

(cid:64)

(cid:161)

(cid:161)
=

(cid:161)

(cid:161)

mult

(cid:64)

(cid:64)(cid:64)(cid:82)

(cid:161)(cid:161)(cid:170)

(cid:63)
C

The category C can be quite arbitrary. Of course, if the category fails to
have certain structures, there may be very few models. For example, there
can be no models of the monoid sketch if the category lacks a terminal object.
Similarly, in order for there to be a model with underlying object C, both
C × C and C × C × C must exist.

Suppose that (C, multC, unitC) and (D, multD, unitD) are two models
of the sketch for monoids in the category C . An arrow f : C −→ D is a
homomorphism of models if the diagrams

C × C

(cid:45)f × f

D × D

multC

multD

(cid:63)
C

(cid:63)
D(cid:45)

f

1

(cid:161)

(cid:161)

(cid:64)

(cid:64)

unitC
(cid:161)

(cid:161)

(cid:161)(cid:161)(cid:170)

C

f

(cid:64)

unitD
(cid:64)

(cid:64)(cid:64)(cid:82)
D(cid:45)

commute. The result is a category Mon(C ) of monoids of C . This category
comes equipped with an underlying functor Mon(C ) −→ C . In many cate-
gories C , there is a functor which behaves like the free monoid functor in
Set discussed in 13.1.2.

7.4.5 Exercises

1. Let S be the sketch of Exercise 1 of Section 7.2. Show that the category
of models of S in Set is isomorphic to Set.

2. Let S be a sketch with two nodes a and b, two arrows f : a −→ a and
g : a −→ b, and one cone

a

(cid:161)

f
(cid:161)(cid:170)

(cid:161)

g(cid:64)
(cid:64)
(cid:64)(cid:82)

a

b

7.5 The theory of an FP sketch

237

Let T be a sketch with three nodes a, b and c, ﬁve arrows f : a −→ a, g : a
−→ b, h : a −→ c, j : c −→ a and k : a −→ c, one cone

a

(cid:161)

k
(cid:161)
(cid:161)(cid:170)

g(cid:64)
(cid:64)
(cid:64)(cid:82)

c

b

a

a(cid:45)f

and two diagrams

a

(cid:190)

(cid:45)h

c

j

(cid:64)
(cid:64)
k

(cid:64)

(cid:64)(cid:82)

h
(cid:63)
c

Show that the category of models of S and of T in any category C with
ﬁnite products are equivalent.

7.5 The theory of an FP sketch

In 4.6.11, we constructed, for each linear sketch S , a category Th(S ) with
the property that there is a model M0 : S −→ Th(S ) and such that for
each category C and each model M : S −→ C , there is a functor F : Th(S )
−→ C such that F ◦ M0 = M . The analog for FP sketches is given by the
following.

7.5.1 Theorem Given any FP sketch S , there is a category ThFP(S )
with ﬁnite products and a model M0 : S −→ ThFP(S ) such that for any
model M : S −→ C into a category with ﬁnite products, there is a functor
F : ThFP(S ) −→ C that preserves ﬁnite products for which

(i) F ◦ M0 = M , and
(ii) if F (cid:48) : ThFP(S ) −→ C is another functor that preserves ﬁnite products
for which F (cid:48) ◦ M0 = M , then F and F (cid:48) are naturally isomorphic.

We do not prove Theorem 7.5.1 here. A proof that constructs ThFP(S )
as a full subcategory of a very special kind of category called a topos (which
implies useful properties of ThFP(S )) may be found in [Barr and Wells,
1985], Section 4.3, Theorem 1 (p. 150), where it is also shown that the
category of models of S is equivalent to the category of models of ThFP(S ).
Toposes are discussed in Chapter 15. References concerning the construction
of theories of sketches of various kinds are given in Section 10.4.

238

Finite product sketches

7.5.2 Terminology A category T with ﬁnite products is called an FP
theory, and a model of an FP theory in a category C which has ﬁnite prod-
ucts is a functor F : T −→ C that preserves ﬁnite products. Theorem 7.5.1
can be described as saying that every sketch S has a universal model M0
in an FP theory ThFP(S ) with the property that every model of S induces
a model (uniquely determined up to natural isomorphism) of ThFP(S ).

7.5.3 Theorem Let M, M (cid:48) : S −→ C be models of an FP sketch in a cat-
egory C with ﬁnite products. Then any homomorphism of models α : M
−→ M (cid:48) extends uniquely to a natural transformation (cid:98)α : F −→ F (cid:48), where F
and F (cid:48) are the models of ThFP(S ) in C given by Theorem 7.5.1 that corre-
spond respectively to M and M (cid:48). The passage from M to F and from α to (cid:98)α
is a functor, and in fact is an equivalence of categories between Mod(S , C )
and Mod(ThFP(S ), C ).

We omit the proof, but point out that (cid:98)α is induced from α by a general-
ization of the way in which a semigroup homomorphism from S to S(cid:48) induces
a map from S × S to S(cid:48) × S(cid:48), as described in the proof of the converse part
of Proposition 7.4.3.

7.5.4 The theory ThFP(S ) is deﬁned up to equivalence by the following
properties:

FPT–1 ThFPS has all ﬁnite products.
FPT–2 M0 takes every diagram of S to a commutative diagram in ThFPS .
FPT–3 M0 takes every cone of S to a product cone of ThFPS .
FPT–4 No proper subcategory of ThFPS includes the image of M0 and

satisﬁes FPT–1, FPT–2 and FPT–3.

Two theories of an FP sketch S need not be isomorphic because, for
example, in one of them A × B might be the same as B × A, whereas in
another the two might be diﬀerent, although, of course, A × B and B × A
are always isomorphic. As just stated, however, two theories of S are always
equivalent. A category theorist normally regards the question as to whether
two isomorphic objects are actually the same as irrelevant, and therefore will
not usually care which of several equivalent categories she is working in. For
this reason we customarily refer to the theory ThFP(S ) as ‘the’ theory of
S .

7.5.5 In general, giving an explicit description of the theory of a sketch is
recursively unsolvable, since the general word problem for groups or semi-
groups can be expressed as the question of whether two arrows in the free
category generated by the graph of a sketch generate the same arrow of a
theory. However, we can give some explicit examples of theories.

7.6 Initial term models

239

For example, the theory of 7.1.5 has two objects, 1, which is a terminal
object, and n. It has an arrow 0 : 1 −→ n, an arrow (cid:104)(cid:105) : n −→ 1, and a family
succk : n −→ n of arrows for k = 1, 2, . . ., which are the n-fold composites
of the arrow succ : n −→ n. And those, with the identity arrows, are all the
arrows, and they are all diﬀerent. With this description, M0 is an inclusion.
In Section 4.7, we discussed linear sketches with constants. We can now
see that these are special types of FP theories, representing each constant as
an arrow from an object 1 which must be the vertex of a cone with empty
base. We did not discuss the theory of a linear sketch with constants, but it
is now clear that such sketches, since they are FP sketches, do have theories.

7.5.6 The theory of the sketch 7.2.1 for semigroups is more complicated.
We will again describe it in such a way that the universal model M0 is an
inclusion.

The theory consists of objects sn for n = 0, 1, . . . . It has as arrows all the
projection arrows necessary to make sn an n-fold product of s, the arrow
c : s2 −→ s for the binary operation, all the composites of these arrows with
each other, and all induced arrows such as (cid:104)c, c(cid:105) : s2 −→ s2, c × p1 : s3 −→ s2,
and so on. Thus it has all the arrows you need to give all the diagrams in 7.2.3
and a great many more. Moreover, all the diagrams in 7.2.3 commute.

It is easy to construct sketches for which M0 is not injective on arrows (for
example, include a diagram forcing two arrows to be the same), so cannot be
treated as an inclusion, but this is not true of most interesting sketches – if
you have two diﬀerent arrows in a sketch, you probably already know a model
where they are diﬀerent, and then the universality of M0 implies that M0 has
to take them to diﬀerent arrows.

7.6 Initial term models for FP sketches

Just as in the case of a linear sketch with constants (see 4.7.11), a set-valued
model of an FP sketch is called a term model if each element of the value at
each node is forced to be there by the sketch. In the ﬁrst instance, the node
forced to be a terminal object is forced to have a unique element. But then
by applying various operations, other elements are forced to exist. A term
model has only those elements forced to exist in this way. This is spelled out
precisely below in 7.6.5.

7.6.1 Deﬁnition A model of an FP sketch in an arbitrary category C is
called an initial model or initial algebra if it has a unique homomorphism
of models to each other model. It is thus an initial object in the category of
models of the sketch in C .

240

Finite product sketches

7.6.2 A particular example is a natural numbers object in a category C
with terminal object. Using the characterization given in Section 5.5, it is
not hard to see that a natural numbers object is an initial model of the
sketch given in 7.1.5.

7.6.3 As with linear models with constants, an initial model of an FP
sketch in the category of sets is necessarily a term model. For let M0 be
an initial model and suppose it is not a term model. Then the typed set
of elements that are reachable beginning from the constants is certainly a
model of the theory. It admits the constants and is closed, by deﬁnition,
under the operations. Thus there is a term model M1 ⊆ M0. (The same ar-
gument, by the way, shows that every model includes a least submodel and
that is a term model.)

Now we have an arrow (unique, actually) f : M0 −→ M1 by the deﬁnition
of initial model. That arrow, composed with the inclusion, gives an arrow M0
−→ M0. But there is just one arrow from M0 to itself, the identity (because
M0 is an initial model). Thus the composite must be the identity. But the
image of f is included in M1, so that M1 = M0, which means that M0 is a
term model, as claimed.

A general version of the preceding argument shows that term models,
hence in particular initial models, have no junk in the sense of Example 4.7.9.

7.6.4 Another property any initial model must have is: if t and u are two
terms deﬁnable starting with constants, then in an initial model M0, M0(t) =
M0(u) if and only if M (t) = M (u) in every model M . The nontrivial direction
of that statement follows from the observation that if M (t) (cid:54)= M (u) in some
model, then necessarily N (t) (cid:54)= N (u) in any model N for which there is a
homomorphism N −→ M .

Thus initial models have no confusion (see 4.7.10). They are in fact char-
acterized up to isomorphism by having no junk and no confusion (see 4.7.12).

7.6.5 Construction of initial models for ﬁnite FP sketches FP sketches
always have initial models (see [Barr, 1986b] for a categorical proof). We
now revise the construction of 4.7.11 to construct initial models for ﬁnite
FP sketches.

Let S = (G , D, L ) be an FP sketch. In the construction of the initial
model of a linear sketch with constants, we constructed terms as strings of
arrows of G . We will now allow tuples of arrows in these strings. The set
AS consisting of all arrows of G , all tuples (of ﬁnite length) of such arrows
and the cones C of L is called the alphabet of the sketch S . The rules
construct an initial model I recursively using these data. The rules apply to

each cone C in L of the form

7.6 Initial term models

241

(cid:161)

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

a1

· · ·

q

pi

(cid:64)

(cid:63)
ai

(cid:64)

pn
(cid:64)

(cid:64)(cid:82)

· · ·

(7.12)

an

FP–1 If f : a −→ b is an arrow of G and [x] is an element of I(a), then

[f x] ∈ I(b) and I(f )[x] = [f x].

FP–2 If (f1, . . . , fm) and (g1, . . . , gk) are paths in a diagram in D, both going
from a node labeled a to a node labeled b, and [x] ∈ I(a), then

(If1 ◦ If2 ◦ . . . ◦ Ifm)[x] = (Ig1 ◦ Ig2 ◦ . . . ◦ Igk)[x]

in I(b).

FP–3 If for i = 1, . . . , n, [xi] is an element in I(ai) (in Diagram (7.12)),
then [C(x1, . . . , xn)] is an element of I(q). (Note that C(x1, . . . , xn)
is a string consisting of the cone C followed by a tuple of arrows.)
In particular, if n = 0, there is a single element [C()] in the empty
product.

FP–4 If for i = 1, . . . , n, [xi] and [yi] are elements in I(ai) for which [xi] =

[yi], i = 1, . . . , n, then

[C(x1, . . . , xn)] = [C(y1, . . . , yn)]

FP–5 For i = 1, . . . , n, we require

FP–6 For x ∈ I(q), we require

[piC(x1, . . . , xn)] = [xi]

[x] = [C(p1x, . . . , pnx)]

Thus FP–3 forces the vertex of the cone to contain an element represent-
ing each tuple of elements in the factors a1,. . . ,an, and FP–5 forces the pi
to be the coordinate projections. Because it applies to empty cones, FP–3
subsumes I–1 of 4.7.11, which has no direct counterpart here. Observe that
it follows from FP–1 and FP–5 that

I(pi)[C(x1, . . . , xn)] = [xi]

for each i. FP–4 may be regarded as an extension of the deﬁnition of ‘con-
gruence relation’ to cover the case of tuples.

242

Finite product sketches

7.6.6 Examples
If M is the initial term model for an FP sketch S , then
for each sort g of the graph G of the sketch, M (g) contains just those el-
ements forced to be there by applying operations to constants. Indeed, up
to isomorphism of models the elements are the formal applications of op-
erations to constants, identifying those which the diagrams force to be the
same.

Thus for the sketch in 7.1.5, I(1) must be a singleton set, and I(zero)
applied to that single element is an element of I(n) which we may call
0. Then the elements of the sort I(n) are just 0, succ(0), succ(succ(0)),
succ(succ(succ(0))), and so on. These can be identiﬁed as the natural num-
bers, starting at zero.

From this point of view, 7.1.5 is a simple data type description, and the

initial model is then the set of possible values of that type.

Many other data types have been described using initial models using
signatures and equations rather than FP sketches. (See the references at the
end of this section.) We will present some of these in Section 8.1 after we
have introduced ﬁnite sums, which allow us to distinguish exceptional cases
such as an empty stack or a null node on a tree.

7.6.7 Sketching context free grammars A context free grammar (de-
ﬁned in 4.8.14) is equivalent to a sketch whose initial model consists of
derivations; the languages corresponding to each nonterminal form another
model. Given a grammar with set T of terminals, N of nonterminals and P
of productions, the sketch S corresponding to the grammar can be deﬁned
as follows:

CFG–1 The nodes consist of all the nonterminals and all the terminals
(which are not formal terminal objects), as well as a formal terminal
object 1 and a node rp for the right hand side of each production p.
CFG–2 The arrows consist of one constant 1 −→ t for each terminal t, an
arrow rp −→ V for each production p = V −→ w (the arrow goes the
opposite way from the production), and projection arrows for the
cones listed below.

CFG–3 There are no diagrams.
CFG–4 There is an empty cone with vertex 1.
CFG–5 For each production p = V −→ w, let w = a1a2 · · · an where each
ai is a terminal or a nonterminal. Then there is a cone with base
{a1, a2, . . . , an} and with vertex rp.

If I is the initial algebra of the sketch and V is a nonterminal, then
I (V ) consists of all derivations with root V and terminals at the leaves,
and if t is a terminal, then I (t) is a singleton.

7.6 Initial term models

243

In a model M , each production p = V −→ a1a2 · · · an can be regarded as
the n-ary operation that takes a tuple of elements of M (a1) × M (a2) × · · · ×
M (an) to M (V ). In the case of the initial model I this attaches the trees
in M (ai) in left to right order as subtrees of a tree in I (V ).

There is another model L of this sketch. It is the same as I on terminals.
If V is a nonterminal, the elements of L (V ) are the strings of terminals
that can be derived from V . (Thus if S is the start symbol, L (S) is the
set of strings usually called the language generated by the grammar.) A
production p = V −→ a1a2 · · · an concatenates the strings in L (a1)×L (a2)×
· · · × L (an) to produce a string in V . The unique map from I to L takes
a derivation tree to its string of leaves. This map is an isomorphism if and
only if the grammar is unambiguous (this can be taken as the deﬁnition of
unambiguity).

More information about this construction may be found in [Wells and

Barr, 1988].

7.6.8 Free algebras Let S be a sketch with set S of nodes. Recall from 2.6.11
that an S-indexed set is a set X together with a typing function τ : X −→ S.
Our point of view is that the nodes of the sketch represent types and that
X is a set of typed constants. If τ : X −→ S and τ (cid:48) : X (cid:48) −→ S are sets typed
by the same sketch S , then a function f : X −→ X (cid:48) is a typed function
if τ = τ (cid:48) ◦ f . Sets typed by S and typed functions form the slice category
Set/S.

A particular example of a typed set is any model M of S in Set for
which M (c) and M (d) have no elements in common for distinct nodes c and
d. Any model is isomorphic to such a model, obtained by taking the disjoint
union of the values of M at the diﬀerent nodes of S . A model is thus a
family of sets, indexed by S, but we can as well think of it as a single set
(the union) typed by S. In any case, the underlying (family of) set(s) of a
model is an object of the slice category Set/S.

Now given an S-indexed set X, let SX be the sketch constructed by
adding to the graph of S a set of arrows x : 1 −→ s for each element x ∈ X
of type s. These are in addition to any constants of type S already given in
the sketch. An initial model of SX , if one exists, is called the free algebra
generated by the typed set X. We use the deﬁnite article because, although
not unique, it is unique up to a unique isomorphism that preserves the set
X for the same reason that initial algebras are always unique.
The following theorem gives the main existence result.

7.6.9 Theorem Let S be an FP sketch. Then for any set X typed by the
set of nodes of S , there is a free algebra generated by X.

244

Finite product sketches

The free algebra on X is denoted F (X). This theorem follows from the
fact that any FP sketch, in fact any sketch with cones but no cocones (see
Chapter 10), has an initial algebra, and of course SX is an FP sketch. An
accessible proof of this fact is in [Barr, 1986b].

7.6.10 The map lifting property Free algebras have the map lifting
property described in 3.1.14. This topic is continued in Section 10.2 and
Section 13.2.

7.6.11 Theorem Let S be an FP sketch, X a typed set and M a model
of S in sets. Then any typed function f : X −→ M has a unique extension
to an arrow between models F (X) −→ M .

7.6.12 Example Let us see how our deﬁnition of free model allows us to
discover that the free semigroup on a one element set is isomorphic to the
semigroup (N+, +).

a

Let the set be {a}. Thus we must construct the initial term model I
of the sketch for semigroups with one arrow 1
−−→ s added; let us denote
this sketch by Sa. We write c(x, y) as xy. It follows that I(s) must have
elements [a], [a][a], [a][a][a], and so on. Let us call them simply a, a2, a3,
. . . an, . . .. Now (N+, +) is a model M of Sa with M (s) = N+, M (c) = +
and M (a) = 0. (N is also a model of Sa in other ways, but this is the
way in which it is free on one generator.) Therefore by initiality there must
be a unique homomorphism h : I(s) −→ (N+, +) that takes a to 0. Then h
necessarily takes an to n for each n ∈ N+. Since aman = am+n (see 2.3.5),
there is also a homomorphism k : (N+, +) −→ I(s) that takes n to an. It
follows that h is an isomorphism with inverse k.

Note that it follows from this that there are no elements of I(s) other
than those of the form an. It is instructive to think about how you would
prove this by a direct analysis of the sketch Sa.

7.6.13 Specifying pairs The sketch S for semigroups has other nodes
besides s. For example, one can construct a free algebra F with an element
t of type s × s by constructing the initial algebra for the sketch St, where
t : 1 −→ s × s is a new arrow adjoined to S . F (s) would necessarily have
two elements a = F (p1)(t) and b = F (p2)(t), where p1, p2 : s × s −→ s are the
product projections. On the other hand, if you constructed a free algebra G
for S with two elements a, b of type s, then G(s × s) would have to have
an element C(a, b). This is a reﬂection of the fact that, as a product, there
is a bijection between elements of G(s × s) (which is G(s) × G(s)) and pairs
of elements of G(s). It follows that any free algebra is equivalent to one in
which all the elements that are speciﬁed are elements of s. A more general
form of this observation is used in 9.7.

7.7 Signatures and FP sketches

245

7.6.14 Initial algebra semantics in the literature The initial algebra
semantics of multisorted signatures and equations is equivalent to the initial
algebra semantics of FP sketches. This approach has been developed exten-
sively by Goguen and others. The idea is to give an algebraic speciﬁcation of
a data type (using a signature or an FP sketch) which explicitly speciﬁes all
the behavior of the type accessible to the program writer. The corresponding
initial algebra is then an implementation of this speciﬁcation: the terms in
the algebra (arrows) are in fact the data inhabiting that type. The point is
that the terms in the initial algebra, as we have seen in 7.6.5, can be con-
structed entirely from the given description, thus constructing the semantics
out of the syntax.

This is discussed in the sketch case by [Gray, 1987] and [Wells and
Barr, 1988]. The approach via signatures is described in [Goguen, Thatcher
and Wagner, 1978], [Zilles, Lucas and Thatcher, 1982] and [Meseguer and
Goguen, 1985]. In many cases, extensions to the idea have been proposed, for
example in [Goguen et al., 1977], [Goguen, Jouannaud and Meseguer, 1985]
and [Lellahi, 1989]. More references are given at the end of the next section.

7.6.15 Exercises

1. What is the initial model of the sketch of 7.1.6? (Note: It is not the model
M described in 7.1.6.)

2. Let S be the sketch with three nodes, 1, d and l, three arrows u : 1 −→ l,
head : l −→ d and tail : l −→ l, no diagrams, and two cones, one empty with 1
at the vertex and the other C given by

l

(cid:161)

(cid:161)

head
(cid:161)
(cid:161)(cid:170)

d

(cid:64)

(cid:64)

tail
(cid:64)
(cid:64)(cid:82)

l

What is the initial model of S ? (S is the sketch of 7.1.6 without the con-
stants a and b but with a constant u of type l.)

3. Let X be a set with two elements. Explain how the free model of Ex-
ample 7.1.5 on X can be thought of as the disjoint union of three copies of
N.

7.7 Signatures and FP sketches

We will describe a formal version of the method of signatures and equations
similar to that used by many authors in the literature and show how to
produce an FP sketch with essentially the same models in the sense of 7.2.8.

246

Finite product sketches

7.7.1 Deﬁnition A signature S = (Σ, Ω) is a pair of ﬁnite sets Σ and
Ω. The elements of Σ are sorts, which will usually be denoted by lowercase
Greek letters. The elements of Σ∗ (the set of words of ﬁnite length in Σ –
including the empty word) are called arities. The elements of Ω are oper-
ations, denoted by lowercase English letters. Each operation f ∈ Ω has an
arity in Σ∗ and a sort in Σ. The arity gives the input type and the sort is
the output type.

A model M of the signature S is a collection of sets Mσ indexed by Σ and
a collection of functions Mf indexed by Ω with the property that if σ1σ2 . . . σn
is the arity of f and τ is the sort of f , then Mf : Mσ1 × Mσ2 × · · · × Mσn
−→ Mτ . When n = 0, Mf is interpreted to mean a function from the one-
element set to Mτ , that is an element of Mτ .

7.7.2 Terms
In general, one is interested in structures deﬁned by a signa-
ture which satisfy certain equations. For example, to describe a semigroup,
we need a binary operation that sends (x, y) to x ∗ y and we also have to
express the associative law that says x ∗ (y ∗ z) = (x ∗ y) ∗ z, that is that two
terms are equal in any model. To do this in a formal way requires that we
deﬁne terms for a signature.

Given a set V of variables x, y, . . . sorted by Σ (meaning that each variable
is assigned a speciﬁc sort in Σ) we can deﬁne a set of terms of S recursively
by T–1 and T–2 below.

Each term t has an arity A(t) = w ∈ Σ∗, a sort S(t) = σ ∈ Σ, and
a variable list VL(t) = v ∈ V ∗. T–1 and T–2 deﬁne the arity, sort and
variable list. Maintaining the information about the arity is redundant (but
convenient) since the arity of the term is the list of sorts (in order) of the
variables in the variable list and so is recoverable from the variable list. The
reverse is not true: the arity does not indicate which variables are repeated.

T–1 If x is a variable of sort σ, then x is a term of arity A(x) = ‘σ’, sort

S(x) = σ and variable list VL(x) = ‘x’.

T–2 If for i = 1, . . . , n, ei is a term of arity wi ∈ Σ∗, sort σi ∈ Σ and variable
list li ∈ V ∗, and f is an operation of arity σ1σ2 . . . σn and sort τ in
Ω, then t = f (e1, e2, . . . , en) is a term of arity A(t) = w1w2 · · · wn (this
is the concatenate of the strings wi), sort S(t) = τ and variable list
VL(t) = l1l2 . . . ln.

Terms stand in much the same relation to signatures as arrows of the

theory of the sketch do to the graph of the sketch.

7.7.3 Example To give you a clue as to what this deﬁnition does, here is
an example: if we have a signature S with

(i) sorts σ and τ in Σ,

7.7 Signatures and FP sketches

247

(ii) operations m of arity ‘σσ’ and sort τ and f of arity ‘στ τ ’ and sort σ,

and

(iii) variables x, y of sort σ and z of sort τ in V ,

then f (y, m(x, y), z) is a term of arity ‘σσστ ’, sort σ and variable list ‘yxyz’.

7.7.4 Equations An equation for the signature S is a formula of the
form t = u, where t and u are terms of the same sort. They do not have to
have the same arity or variable list.

An equation has an obvious interpretation in any model of the signature.
Such a model M satisﬁes a set E of equations if for every equation t = u in
E, t and u have the same interpretations in M . The models for a signature
satisfying a set of equations form an equational variety.

7.7.5 The sketch corresponding to a signature with equations If
S is a signature with equations E, we can construct a sketch S (S, E) whose
models in Set which take products to canonical products are exactly the
models of (S, E).

To begin with, the graph of S (S, E) should have a node labeled σ for
each sort σ of S, plus a node labeled σ1 × · · · × σn for each string σ1 · · · σn
which is the arity of an operation. For each such arity, S (S, E) must have a
cone with vertex σ1 × · · · × σn and base σ1, . . . , σn. There must be an arrow
with the proper source and target for each operation of S.

The equations in E must be speciﬁed by diagrams of S (S, E), a compli-
cated process which in general also requires adding arrows and nodes to its
graph. There are two problems with this construction. The ﬁrst is that in
any equation t = u, the variables that appear in t and u are not necessarily
the same. The second is that a variable may appear more than once in a
term (compare 6.5.2). It is interesting to note that these two possibilities are
what distinguish ordinary logic – based on cartesian product – from Girard’s
linear logic [Girard, 1987], [Girard, Taylor and Lafont, 1989], which is based
on another kind of product.

7.7.6 In order to describe how to express the equations in a sketch, we
will associate with each term t a path in a certain graph. Since there are
inﬁnitely many terms, there will be inﬁnitely many such paths. On the other
hand, it is convenient to keep the graph ﬁnite. Thus in the sketch associated
to a signature with equations, we will add only such nodes and arrows as
are necessary to state the given equations. If there are just a ﬁnite set of
operations and equations, then the resultant sketch will be ﬁnite.

In the descriptions below are a number of nodes and arrows which in-
volve formal products, identities and projections. We will suppose without
mention that the appropriate cones and diagrams to express the fact that

248

Finite product sketches

these become actual products, identities and projections are included in the
sketch.

Our approach will be to associate with each term t a ‘pseudo-path’ Q(t)
that is the same as the path of the term with the same operations but
no repeated variables. Then we show how to turn these pseudo-paths into
diagrams in a way which takes into account the repeated variables. Note that
the actual path of a term t can be recovered by applying this construction
to the equation t = t, which results in a diagram with two identical paths,
each the path of t.

Now let t be a term of sort σ, arity ‘σ1 · · · σn’ and variable list ‘v1 · · · vn’.
We will describe a path Q(t) that starts at σ1 ×· · ·×σn and ends at σ. This is
deﬁned inductively as follows. If x is a variable of type τ , then Q(x) = id : τ
−→ τ . If t1, . . . , tm are terms of sort τ1, . . . , τm, respectively, and if the
concatenate of their arities is ‘σ1 · · · σn’, and if f is an operation of arity
‘τ1 · · · τm’ and sort σ, then Q(f (t1, . . . , tm)) is the composite path

σ1 × · · · × σn

Q(t1) × · · · × Q(tm)

(cid:45)

τ1 × · · · × τm

σ(cid:45)f

Now suppose that we have an equation t = u. Suppose that the arities of
t and u are ‘σ1 · · · σn’ and ‘τ1 · · · τm’ respectively. Let X = {x1, . . . , xk} be
the set of variables that appear anywhere in t or u and suppose that xi has
sort ρi. The sketch will have an arrow

v : ρ1 × · · · × ρk −→ σ1 × · · · × σn

and, for each i = 1, . . . k, a diagram

ρ1 × · · · × ρk

σ1 × · · · × σn

(cid:45)v
(cid:72)(cid:72)(cid:72)

ρi
(cid:72)(cid:72)(cid:72)(cid:106)

ρi
(cid:63)
σ

where j is chosen so that the jth variable in the variable list of t is xi. We
similarly have an arrow

w : ρ1 × . . . × ρk −→ τ1 × . . . × τm

and a similar set of diagrams. Finally, we add the diagram Q(t) ◦ v = Q(u) ◦
w to the set of diagrams. It is this diagram that expresses the equation that
t = u.

7.7 Signatures and FP sketches

249

7.7.7 An example The above may appear rather complicated; here is
how the construction looks when applied to a speciﬁc case. Let the sig-
nature S and the operations f and m be as in 7.7.3. Let t be the term
f (y, m(x, y), z). Let u be the term x of arity σ and sort ‘σ’ and variable list
‘x’. We will work out the diagram corresponding to the equation t = u, that
is, f (y, m(x, y), z) = x. The path Q(t) is

σ × σ × σ × τ

id ×m × id

(cid:45)

σ × τ × τ

σ(cid:45)f

The path of u is id : σ −→ σ. The variable list of t is the string ‘yxyz’
and that of u is the string ‘x’. Thus the set of all variables that appear in
either list is {x, y, t}. The sorts of the variables are σ, σ and τ , respectively.
Accordingly, we form the diagram

σ × σ × τ

v = (cid:104)p1, p2, p1, p3(cid:105)
(cid:45)

σ × σ × σ × τ

w = p1

(cid:63)
σ

id

id ×m × id
(cid:63)

σ × τ × τ

f
(cid:63)

σ(cid:45)

The top arrow (cid:104)p1, p2, p1, p3(cid:105) is exactly what is needed to transform the
variable set {x, y, t} into the variable list xyxt. Of course a set is not ordered,
but our notation forces us to choose an ordering of it. If we had chosen to
write the set as {t, x, y}, then the top arrow would have been

(cid:104)p2, p3, p2, p1(cid:105) : τ × σ × σ −→ τ × σ × σ × σ

The bottom arrow labeled identity could have been omitted – or rather
replaced by the null arrow. However, this would have made the inductive
step harder.

In applications it is generally necessary to associate a list of variables
with each term or equation, as we did in Section 6.3. This is done in detail
in [Bagchi and Wells, 1997b].

7.7.8 FP sketches and multisorted algebraic theories The discus-
sion in this section shows informally that FP sketches have the same ex-
pressive power as multisorted algebraic theories, at least as far as models in
Set are concerned, and the considerable literature on applications of mul-
tisorted algebra to computer science provides examples of applications of
FP sketches. See in particular [Ehrig and Mahr, 1985], [Wagner, Bloom and

250

Finite product sketches

Thatcher, 1985], [Bloom and Wagner, 1985], [Gray, 1987], [Gray, 1990] and
[Ehrich, 1986]. Other references, concentrating on initial algebra semantics,
were mentioned in 7.6.14. The approach via sketches makes it natural to
consider models in an arbitrary category, for example a category such as
modest sets designed speciﬁcally for programming language semantics. This
is an advantage over the usual formulation of multisorted universal algebra,
which considers only models in sets.

One would expect that a reformulation of universal algebra which puts models
in other categories on the same footing as models in sets would wind up looking
rather like FP sketches. In particular, the formulation would necessarily carry
explicit information about the projection arrows of cones.

7.7.9 Exercise

1. A binary operation ∗ is said to distribute over a binary operation + if
x ∗ (y + z) = x ∗ y + x ∗ z holds for all x, y and z. Express this law using the
techniques of this section.

8
Finite discrete sketches

This chapter discusses FD (ﬁnite discrete) sketches, which are a more general
kind of sketch than that described in Chapter 7. The sketches described
here allow the speciﬁcation of objects which are sums as well as products.
Section 8.1 introduces these sketches. Section 8.2 gives a detailed description
of the sketch for ﬁelds as an example of an FD sketch. In Section 8.3, we
show how to modify initial algebra construction so that it works for FD
sketches. FD sketches have theories, too, but discussion of that is postponed
until Chapter 10.

8.1 Sketches with sums

Using sum cocones as well as product cones in a sketch allows one to express
alternatives as well as n-ary operations.

8.1.1 A ﬁnite discrete sketch, or FD sketch, S = (G , D, L , K ), con-
sists of a ﬁnite graph G , a ﬁnite set of ﬁnite diagrams D, a ﬁnite set L of
discrete cones with ﬁnite bases, and a ﬁnite set K of discrete cocones with
ﬁnite bases. A model of the FD sketch S in Set is a graph homomorphism
M : G −→ Set which takes the diagrams in D to commutative diagrams, the
cones in L to product cones, and the cocones in K to sum cocones.

8.1.2 The sketch for lists The FD sketch for ﬁnite lists illustrates how
FD sketches can be used to specify a data type which has an exceptional
case for which an operation is not deﬁned. (Compare 7.1.6.) The graph has
nodes 1, d (the data), l (the lists) and l+ (the nonempty lists). There are no
diagrams. There is a cone with empty base expressing the fact that 1 must
become a terminal object in a model, another cone

l+

(cid:161)

(cid:64)

head
(cid:161)(cid:170)

(cid:161)

(cid:64)

tail
(cid:64)(cid:82)

d

l

251

252

Finite discrete sketches

and one cocone

1

(cid:64)

(cid:64)

(cid:64)(cid:82)

l+

(cid:161)

(cid:161)

(cid:161)(cid:170)

l
These can be summed up in the expressions l+ = d × l (a nonempty list
has a datum as head and a list as tail) and l = 1 + l+: (a list is either the
empty list – the single member of the terminal set – or a nonempty list).
The fact that a sum becomes a disjoint union in a model in Set enables us
to express alternatives in the way exhibited by this description. We thereby
avoid the problem mentioned in 7.1.6: we can deﬁne head for only nonempty
lists because we have a separate sort for nonempty lists.

If S is any ﬁnite set, there is a model M of this sketch for which M (d) = S,
M (1) is the singleton set containing only the empty list (cid:104)(cid:105), M (l) is the set of
ﬁnite lists of elements of S, and M (l+) is the set of ﬁnite nonempty lists of
elements of S. M (head) and M (tail) pick out the head and tail of a nonempty
list. This is an initial term algebra (to be deﬁned in Section 8.3) for the sketch
extended by one constant for each element of S.

8.1.3 Given a ﬁnite set S, the model M just mentioned is certainly not the
only model of the sketch for which M (d) is S. Another model has M (l) all
ﬁnite and inﬁnite lists of elements of S, with M (l+) the nonempty lists and
M (head) and M (tail) as before. This model contains elements inaccessible
by applying operations to constants: you cannot get inﬁnite lists by iterating
operations starting with constants. They are junk as deﬁned in 4.7.9.

8.1.4 The sketch for natural numbers We will now modify the sketch
7.1.5 in a way which shows how FD sketches can model overﬂow.

The graph contains nodes we will call 1, n, nover and n + nover, which
we interpret, respectively, as a one-element set, a set of natural numbers (of
which there may be only ﬁnitely many), an overﬂow element and the set of
all natural numbers. The only cone is the one implicit in the name 1: the
cone has 1 as the vertex and the empty base. There is similarly a (discrete)
cocone implicit in the name n + nover. There is a constant operation zero : 1
−→ n and a unary operation succ : n −→ n + nover. There are no diagrams.

There are many models of this sketch in Set. Here are three of them.

They are all term models.

8.1.5 The ﬁrst model is the set of natural numbers. The value of zero is
0 and succ(i) = i + 1. The model takes nover to the empty set. This model
illustrates the fact that models are permitted to take the empty set as value

8.1 Sketches with sums

253

on one or more nodes. Classical model theorists have not usually allowed
sorts in a model to be empty.

8.1.6 The second model takes n to the set of integers up to and including
an upper bound N . The value at nover is a one- element set we will call ∞,
although any other convenient label (including N + 1) could be used instead.
As above, the value of zero is 0. As for succ, it is deﬁned by succ(i) = i + 1 for
i < N , while succ(N ) = ∞. Note that the domain of succ does not include
∞.

8.1.7 The third model takes for the value of n also the set of integers up
to a ﬁxed bound N . The value of zero is again 0 and of nover is empty. The
operation succ is deﬁned by succ(i) = i + 1, for i < N while succ(N ) = 0.
This is arithmetic modulo n.

This third model could be varied by letting succ(N ) = N or, for that
matter, any intermediate value. This shows that these models really have at
least two parameters: the value of N and what happens to the successor of
N .

8.1.8 Finite state machines It is instructive to create an FD sketch
for ﬁnite state machines as described in Section 3.2.5. We assume a ﬁxed
alphabet A and we assume that the states are divided into acceptor states
and non-acceptor states; we do not distinguish a start state (thus each state
q of the machine determines a language, the language of all strings that drive
the machine from state q to an acceptor state). We will produce a sketch
whose models include machines with an inﬁnite number of states, so we call
its models simply “state machines”. Note that all models will have the same
alphabet A.

For this purpose we describe a state machine M as a tuple

M = (A, S, φ, Y )

where A is an alphabet, S is a set of states, φ : A × S −→ S is the transition
function, and Y is the subset of A of acceptor states.

The sketch S for state machines can be described as follows:

SM–1 The graph of S has three nodes, S, Y and N .
SM–2 The graph has a set of arrows φa : S −→ S indexed by the ﬁxed al-
phabet A. (In a model, φa will become the curried function φ(a, −).)
In addition there are arrows iY : Y −→ S and iN : N −→ S.

254

Finite discrete sketches

SM–3 There are no cones and one cocone:

Y

N

(cid:64)
iY

(cid:64)

(cid:64)(cid:82)

(cid:161)
iN

(cid:161)

(cid:161)(cid:170)

S

It is clear that the models of S are state machines with alphabet A.
There is an uninteresting initial model of S , with empty set of states. Much
more interesting is the terminal object in the category of models (the ﬁnal
algebra). A state of the ﬁnal algebra is a subset of A∗ (a language in A). If
a ∈ A and L ⊆ A∗, then φ(a, L) = {w ∈ A∗ | aw ∈ L}. The acceptor states
of the ﬁnal algebra are those languages that contain the empty string. The
unique map from a machine M = (A, S, φ, Y ) to the ﬁnal algebra takes a
state in S to the set of strings in A∗ that drive the machine to an acceptor
state (the language determined by the state). This map is injective if and
only if M is a minimal machine in the sense of the Myhill-Nerode theorem
[Lewis and Papadimitriou, 1981], page 96.

This example is based on [Rutten, 1996]; [Rutten, 1998]. Those papers
describe the analog of induction for ﬁnal algebras (see 4.7.8), which is called
the principle of coinduction. It is based on the fact that a ﬁnal object in a
category has no proper quotients.

8.1.9 Exercises

1. Construct an FD sketch whose only model is the two-element Boolean
algebra.

2. Give an example of a sketch which has no models in Set. (Hint: In Set,
1 + 1 (cid:54)= 1.)

8.2 The sketch for ﬁelds

Another example of an FD sketch is the sketch for the mathematical struc-
ture known as a ﬁeld. The concept of ﬁeld abstracts the properties of the
arithmetic of numbers. We will describe it in some detail here. This section
is used later only as an example in Section 8.3. Rather than deﬁne ‘ﬁeld’ we
will describe the sketch and say that a ﬁeld is a model of the sketch in sets.
The nodes are 1, u, f, f × f and f × f × f . There are operations

FO–1 0 : 1 −→ f .
FO–2 1 : 1 −→ u.
FO–3 + : f × f −→ f .
FO–4 ∗ : f × f −→ f .

8.2 The sketch for ﬁelds

255

FO–5 − : f −→ f .
FO–6 ( )−1 : u −→ u.
FO–7 j : u −→ f .

The reader should note that the two 1’s in FO–2 above are, of course,
diﬀerent. One of them is the name of a node and the other of an operation.
This would normally be considered inexcusable. The reasons we do it anyway
are (a) each usage is hallowed by long tradition and (b) because they are of
diﬀerent type, there is never any possibility of actual clash. The reader may
think of it as an early example of overloading.

The diagrams are:

FE–1 (associativity of +): + ◦ (id ×+) = + ◦ (+ × id) : f × f × f −→ f .
FE–2 (associativity of ∗): ∗ ◦ (id ×∗) = ∗ ◦ (∗ × id) : f × f × f −→ f .
FE–3 (commutativity of +): + ◦ (cid:104)p2, p1(cid:105) = + : f × f −→ f .
FE–4 (commutativity of ∗): ∗ ◦ (cid:104)p2, p1(cid:105) = ∗ : f × f −→ f .
FE–5 (additive unit): + ◦ (cid:104)id, 0 ◦ (cid:104)(cid:105)(cid:105) = + ◦ (cid:104)0 ◦ (cid:104)(cid:105), id(cid:105) = id : f −→ f .
FE–6 (multiplicative unit): ∗ ◦ (cid:104)j, j ◦ 1 ◦ (cid:104)(cid:105)(cid:105) = ∗ ◦ (cid:104)j ◦ 1 ◦ (cid:104)(cid:105), j(cid:105) = j : u −→ f .
FE–7 (additive inverse): + ◦ (cid:104)id, −(cid:105) = + ◦ (cid:104)−, id(cid:105) = 0 ◦ (cid:104)(cid:105) : f −→ f .
FE–8 (multiplicative inverse): ∗ ◦ (j ×j) ◦ (cid:104)id, ()−1(cid:105) = ∗ ◦ (j ×j) ◦ (cid:104)()−1, id(cid:105) =

1 ◦ (cid:104)(cid:105) : u −→ u.

FE–9 (distributive): + ◦ (∗ × ∗) ◦ (cid:104)p1, p2, p1, p3(cid:105) = ∗ ◦ (id ×+);

+ ◦ (∗ × ∗) ◦ (cid:104)p1, p3, p2, p3(cid:105) = ∗ ◦ (+ × id) : f × f × f −→ f .

There are cones deﬁned implicitly and one cocone:

1

(cid:64)
(cid:64)
0

(cid:64)

(cid:64)(cid:82)

f

u

(cid:161)
(cid:161)
j

(cid:161)

(cid:161)(cid:170)

Intuitively, this says that each element of a ﬁeld is either zero or else is an
element of u. u is interpreted as the set of multiplicatively invertible elements
in a model.

8.2.1 An example of a ﬁeld is the set of ordinary rational numbers. Ex-
pressed as a model M of the sketch, the numbers M (0) and M (1) are the
usual ones, M (f ) and M (u) are the sets of all rationals and nonzero ratio-
nals, respectively, and M (j) is the inclusion. The arithmetic operations are
the usual ones. Other familiar examples are the real and complex numbers.

256

Finite discrete sketches

8.2.2 In building a model of this sketch, we would have to start with the
elements 0 and 1 and then begin adding and multiplying them to get new
elements. For example, we could let 2 = 1+1. Now since M (f ) = M (u)+{0},
we have to decide whether 2 ∈ M (u) or 2 ∈ {0}, that is, whether or not
2 = 0. Quite possibly, the only ﬁelds the reader has seen have the property
that 2 (cid:54)= 0. Even so, one cannot exclude out of hand the possibility that
2 = 0 and it is in fact possible: there is a model of this sketch whose value
at f is {0, 1} with the values of the operations being given by the tables:

+ 0
0
0
1
1

1
1
0

∗
0
1

0
0
0

1
0
1

(These tables are addition and multiplication (mod 2).) If, on the other hand,
2 (cid:54)= 0, we can form 3 = 1 + 2. The same question arises: is 3 = 0 or not? It
is not hard to write down a ﬁeld in which 3 = 0.

Suppose that neither 2 nor 3 is 0? We would deﬁne 4 = 1 + 3 (and prove,
by the way, that 2 + 2 = 2 ∗ 2 = 4) and ask whether 4 = 0. It turns out that if
2 (cid:54)= 0 then 4 (cid:54)= 0. In fact, it is not hard to show that any product of elements
of u also lies in u. Thus the ﬁrst instance of an integer being 0 must happen
at a prime. But, of course, it need never happen, since no number gotten by
adding 1 to itself a number of times is zero in the rational, real or complex
ﬁeld.

8.2.3 A homomorphism between ﬁelds must preserve all operations. Since
it preserves the operation ( )−1, no nonzero element can be taken to zero.
Consequently, two distinct elements cannot go to the same element since
their diﬀerence would be sent to zero. Thus ﬁeld homomorphisms are injec-
tive.

From this, it follows that there can be no ﬁeld that has a homomorphism
both to the ﬁeld of two elements and to the rationals, since in the ﬁrst
1 + 1 = 0, which is not true in the second. This implies that the category of
ﬁelds and ﬁeld homomorphisms does not have products.

8.2.4 Exercises

1. Prove that in a ﬁeld, if two elements each have multiplicative inverses,
then so does their product. Deduce that if 4 = 0, then 2 = 0.

2. Prove that the next to last sentence of 8.2.3 implies that the category of
ﬁelds and ﬁeld homomorphisms does not have products.

8.3 Term algebras for FD sketches

8.3 Term algebras for FD sketches

257

A complication arises in trying to extend the construction of initial term
algebras to FD sketches. As we see from the examples of natural numbers and
ﬁelds, an operation taking values in the vertex of a discrete cocone forces us
to choose in which summand the result of any operation shall be. The choice,
in general, leads to nonisomorphic term models which are nevertheless initial
in a more general sense which we will make precise. Diers [1980a], [1980b]
investigates these models (not in the language of sketches) as generalized
adjoints.

8.3.1 Dæmons How to make the choice? Clearly there is no systematic
way. One way of dealing with the problem is to take all choices, or at least to
explore all choices. In the example in Section 8.2 of ﬁelds, we mentioned that
not all choices are possible; once 2 (cid:54)= 0, it followed that also 4 (cid:54)= 0. (Recall
that in that example, saying that something is zero is saying that it is in one
of two summands.)

More generally, suppose we have an FD sketch and there is an operation
s : a −→ b and a cocone expressing b = b1 + b2 + . . . + bn. If we are building a
model M of this sketch and we have an element x ∈ M (a), then M (s)(x) ∈
M (b), which means that we must have a unique i between 1 and n for which
M (s)(x) ∈ M (bi). (For simplicity, this notation assumes that M (b) is the
actual union of the M (bi).)

Now it may happen that there is some equation that forces it to be in one
rather than another summand, but in general there is no such indication.
For example, the result of a push operation on a stack may or may not be an
overﬂow, depending on the capacity of the machine or other considerations.
Which one it is determines the particular term model we construct and it is
these choices that determine which term model we will get.

Our solution is basically to try all possible sequences of choices; some
such sequences will result in a model and others will abort. Thus as we
explore all choices, some will eventually lead to a model; some will not. The
theoretical tool we use to carry out this choice we call a dæmon. Just as a
Maxwell Dæmon chooses, for each molecule of a gas, whether it goes into one
chamber or another, our dæmon chooses, for each term of a model, which
summand it goes into. The following description spells this out precisely.

8.3.2 Deﬁnition Let S be an FD sketch and suppose the maximum num-
ber of nodes in the base of any cocone is κ. A dæmon for S is a function d
from the set of all strings in the alphabet AS (see 7.6.5) of the underlying
FP sketch (in other words, forget the cocones) to the initial segment {1. . κ}
of the positive integers.

258

Finite discrete sketches

8.3.3 We will use a dæmon this way. We assume that the nodes in the base
of each cocone of S are indexed by 1, 2, . . . , k where k ≤ κ is the number of
nodes in that cocone. In constructing an initial algebra, if a string w must
be in a sort which is the vertex of a cocone (hence in the model it must be
the disjoint union of no more than κ sorts), we will choose to put it in the
D(w)th summand. If D(w) > k, the construction aborts. We will make this
formal.

8.3.4 Construction of initial term models for FD sketches This
construction includes the processes in 4.7.11 and 7.6.5; we repeat them here
modiﬁed to include the eﬀects of a dæmon D. The alphabet is the same as
in 7.6.5.

If a node b is the vertex of a cocone with k = k(b) summands, the sum-
mands will be systematically denoted b1, . . . , bk and the inclusion arrows
ui : bi −→ b for i = 1, . . . , k. If b is not the vertex of a cocone, then we take
k(b) = 1, b1 = b and u1 = idb. We denote the congruence relation by ∼ and
the congruence class containing the element x by [x]. Rules FD–3 through
FD–6 refer to a cone C in L of the form:

(cid:161)

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

a1

· · ·

q

pi

(cid:64)

(cid:63)
ai

(cid:64)

pn
(cid:64)

(cid:64)(cid:82)

· · ·

an

FD–1 If ui : ai −→ a is an inclusion in a cocone and [x] ∈ I(ai), then [uix] ∈
I(a) and I(ui)[x] = [uix]. (Thus we ignore the wishes of the dæmon
in this case.)

FD–2 Suppose f : a −→ b in G , f is not an arrow of the form ui, and [x] ∈
I(a). Let j = D(f x) (we ask the dæmon what to do). If j > k(b),
the construction aborts. Otherwise, we let [f x] ∈ I(bj) and I(f )[x] =
[ujf x].

FD–3 For i = 1, . . . , n, let [xi] be a term in I(ai). Let

j = D(C(x1, . . . , xn))

If j > k(q), the construction aborts. If not, put [C(x1, . . . , xn)] in
I(qj).

FD–4 If for i = 1, . . . , n, [xi] and [yi] are elements in I(ai) for which [xi] =

[yi], i = 1, . . . , n, then

[C(x1, . . . , xn)] = [C(y1, . . . , yn)]

8.3 Term algebras for FD sketches

259

FD–5 For i = 1, . . . , n, I(pi)([C(x1, . . . , xn)]) = [xi].
FD–6 For x ∈ I(q),

[x] = [C(p1x, . . . , pnx)]

FD–7 If (cid:104)f1, . . . , fm(cid:105) and (cid:104)g1, . . . , gk(cid:105) are paths in a diagram in D, both going
from a node labeled a to a node labeled b, and [x] ∈ I(a), then

(If1 ◦ If2 ◦ . . . ◦ Ifm)[x] = (Ig1 ◦ Ig2 ◦ . . . ◦ Igk)[x]

in I(b). If

D(f1f2 . . . fmx) (cid:54)= D(g1 . . . gkx)

(causing (If1 ◦ If2 ◦ . . . ◦ Ifm)[x] and (Ig1 ◦ Ig2 ◦ . . . ◦ Igk)[x] to be
in two diﬀerent summands of I(b)), then the construction aborts.

This construction gives a term model if it does not abort. It is an initial
model for only part of the category of models, however. To make this precise,
we recall the deﬁnition of connected component from 4.3.11. It is easy to see
that each connected component is a full subcategory of the whole category
of models.

8.3.5 Proposition For each dæmon for which the construction in FD–1
to FD–6 does not abort, the construction is a recursive deﬁnition of a model
I of S . Each such model is the initial model of a connected component of
the category of models of S , and there is a dæmon giving the initial model
for each connected component.

We will not prove this theorem here. However, we will indicate how each
model determines a dæmon which produces the initial model for its compo-
nent. Let M be a model of an FD sketch S . Every string w which determines
an element of a sort I(a) in a term model as constructed above corresponds
to an element of M (a). That element must be in a unique summand of a;
if it is the ith summand, then deﬁne D(w) = i. On strings not used in the
construction of the term models, deﬁne D(w) = 1, not that it matters.

Our deﬁnition of dæmon shows that one can attempt a construction of an
initial model without already knowing models. In concrete cases, of course,
it will often be possible to characterize which choices give initial models and
which do not.

8.3.6 Confusion maybe, junk no The slogan, ‘No junk, no confusion’
(see 4.7.12 and 7.6.4) is only half true of the initial models for FD theories.
The ‘No junk’ half of the slogan expresses exactly what we mean when we
say that every element is reachable. There are no extraneous elements. ‘No
confusion’ means no relations except those forced by the equations in the

260

Finite discrete sketches

theory. As we will show by example it may happen that some initial models
have confusion and others not. Later we give an example of a sketch that
has more than one unconfused initial model and one that has no unconfused
initial (or noninitial) model.

If there is just one unconfused initial model, that one may be thought of
as a ‘generic’ model. The others remain nonetheless interesting. In fact, it is
likely that the generic model is the one that cannot be accurately modeled
on a real machine.

8.3.7 Example A typical example of a sketch with many initial models
is the sketch for natural numbers with overﬂow. The generic model is easily
seen to be the one in 8.1.5 in which the overﬂow state is empty. The models
with overﬂow in 8.1.6 are all initial algebras for some component of the
category of models, but they have confusion, since nothing in the sketch
implies that the successor of any element can be the same element. None of
these models have junk.

The modular arithmetic models of 8.1.7 are not initial models; in fact they
are all in the same component as the natural numbers since the remainder
map (mod N ) is a morphism of models. They also have no junk.

8.3.8 Example Here is a simple sketch with no generic model. It has two
initial models, each satisfying an equation the other one does not. There are
ﬁve nodes a = b + c, d and 1. There is one constant x of type d, and a single
operation s : d −→ a. The initial models have one element – the constant –
of type d. One of the initial models has an element of type b and the other
an element of type c.

By modifying this example, we can get forced confusion. Add constants y
and z of type b and c, respectively, and cones forcing b and c to be terminal.
Now there are two initial models, one in which s(x) = y and another in which
s(x) = z. Since there is a model in which s(x) (cid:54)= y, there can be no equation
that forces s(x) = y and there is similarly no equation that forces s(x) = z.
But one or the other equation must hold in any model.

It is well known and proved in abstract algebra texts that
8.3.9 Example
the initial ﬁelds are (a) the rational numbers and (b) the integers mod p for
each prime p. (The word for initial model in these texts is ‘prime ﬁeld’.) A
ﬁeld is in the component of the integers mod p if and only if 1 + 1 + . . . + 1
(sum of p 1’s) is zero. These ﬁelds have confusion. Otherwise the ﬁeld is in
the component of the rational numbers, which have no confusion (nor junk).
Duval and Reynaud [1994a, 1994b] show how to implement simultaneous
computation in the initial algebras for a ﬁnite discrete sketch for ﬁelds.

8.3 Term algebras for FD sketches

261

The real numbers and the complex numbers form ﬁelds with the usual

operations. The irrational real numbers constitute junk.

8.3.10 Example The example in 8.1.2 has only one component and hence
a single initial model in which all sorts are empty except the singleton 1. If
you add constants to d, the initial model is just the set of lists of ﬁnite
length of elements of d. In the model discussed there which also has all
inﬁnite sequences, the inﬁnite sequences are junk.

8.3.11 Binary trees We now describe a sketch for ordered rooted binary
trees (called trees in this discussion). ‘Binary’ means that each node has
either no children or two children, and ‘ordered’ means that the children are
designated left and right. This is an example which uses cocones to treat
exceptional cases, in this case the empty tree.

Trees are parametrized by the type of data that are stored in them. We
will say nothing about this type of data, supposing only that it is a type
for which there is an initial model. The way in which the parametrized data
type is ﬁlled in with a real one is described, for example, in Section 11.2.
We would like to thank Adam D. Barr for helpful discussions on how binary
trees operate (especially their error states) on real machines.

The sketch will have sorts 1, t, s, d. Informally, t stands for tree, s for

nonempty tree and d for datum. We have the following operations:

empty : 1 −→ t
incl : s −→ t
val : s −→ d
left : s −→ t
right : s −→ t

The intended meaning of these operations is as follows.

Empty(cid:104)(cid:105) is the empty tree; incl is the inclusion of the set of nonempty
trees in the set of trees; val(S) is the datum stored at the root of S; left(S)
and right(S) are the right and left branches (possibly empty) of the nonempty
tree S, respectively.
We require that

(cid:161)

(cid:161)

s

(cid:64)

val

(cid:63)
d

(cid:161)

left
(cid:161)

(cid:161)(cid:170)

t

(cid:64)

(cid:64)

right
(cid:64)

(cid:64)(cid:82)

t

262

Finite discrete sketches

be a cone and that

1

(cid:64)
empty

(cid:64)

(cid:64)

(cid:64)(cid:82)

t

s

(cid:161)
incl

(cid:161)

(cid:161)

(cid:161)(cid:170)

be a cocone.

There are no diagrams.
The cocone says that every tree is either empty or nonempty. This co-
cone could be alternatively expressed t = s + {empty}. The cone says that
every nonempty tree can be represented uniquely in the form of a triplet
(left(S), val(S), right(S)), and that every such triplet corresponds to a tree.
Note that this implies that left, val and right become coordinate projections
in a model.

Using this, we can deﬁne subsidiary operations on trees. For example, we

can deﬁne an operation of left attachment, lat : t × s −→ s by letting

lat(T, (left(S), val(S), right(S))) = (T, val(S), right(S))

This can be done without elements: lat is deﬁned in any model as the unique
arrow making the following diagram commute (note that the horizontal
arrows are isomorphisms):

M (t) × M (s)

M (t) × (cid:104)left, val, right(cid:105)

(cid:45)

M (t) × M (t) × M (d) × M (t)

lat

(cid:63)
M (s)

(cid:104)left, val, right(cid:105)

(cid:104)p1, p3, p4(cid:105)
(cid:63)
M (t) × M (d) × M (t)

(cid:45)

In a similar way, we can deﬁne right attachment as well as the insertion of a
datum at the root node as operations deﬁnable in any tree. These operations
are implicit in the sketch in the sense that they occur as arrows in the theory
generated by the sketch (see 4.6.11), and therefore are present in every model.

8.3.12 Proposition Supposing there is an initial algebra for the data type,
then the category of binary trees of that type has an initial algebra. If the data
type has (up to isomorphism) a unique initial algebra, then so does the cor-
responding category of binary trees.

Proof. We construct the initial algebra recursively according to the rules:

(i) The empty set is a tree;

8.3 Term algebras for FD sketches

263

(ii) If Tl and Tr are trees and D is element of the initial term algebra for

the data type, then (Tl, D, Tr) is a nonempty tree;

(iii) Nothing else is a tree.

This is a model M0 deﬁned by letting M0(s) be the set of nonempty
trees, M0(t) = M0(s) + {∅} and M0(d) be the initial model of the data type.
Here ‘+’ denotes disjoint union. It is clear how to deﬁne the operations of
the sketch in such a way that this becomes a model of the sketch.

Now let M be any model with the property that M (d) is a model for
the data type. Then there is a unique morphism f (d) : M0(d) −→ M (d) that
preserves all the operations in the data type. We also deﬁne f (t){∅} to be
the value of M (empty) : 1 −→ M (t). Finally, we deﬁne

f (s)((Tl, D, Tr)) = (f (t)(Tl), f (d)(D), f (t)(Tr))

where f (t) is deﬁned recursively to agree with f (s) on nonempty trees. It
is immediately clear that this is a morphism of models and is unique. In
particular, if the data type has, up to isomorphism, only one initial model
then M0 is also unique up to isomorphism.

8.3.13 In Pascal textbooks a deﬁnition for a tree type typically looks like
this:

type TreePtr = (cid:98)Tree;

Tree = record LeftTree, RightTree : TreePtr;

Datum : integer

end;

Note that from the point of view of the preceding sketch, this actually deﬁnes
nonempty trees. The empty tree is referred to by a null pointer. This takes
advantage of the fact that in such languages deﬁning a pointer to a type
D actually deﬁnes a pointer to what is in eﬀect a variant record (union
structure) which is either of type D or of ‘type’ null.

8.3.14 Exercise
1.† a. Show that if S is an FD sketch and f : M −→ N is a homomorphism
between models in the category of sets, then the image of f is a submodel
of N .

b. Show that every model in the category of sets of an FD sketch has a

smallest submodel.

9
Limits and colimits

A limit is the categorical version of the concept of an equationally deﬁned
subset of a product. For example, a circle of radius 1 is the subset of R × R
(R is the set of real numbers) satisfying the equation x2 + y2 = 1. Another
example is the set of pairs of arrows in a category for which the target of
the ﬁrst is the source of the second: this is the set of pairs for which the
composition operation is deﬁned.

A diﬀerent kind of example is division of one integer by another, which
requires that the second argument be nonzero. This can be made an equa-
tional condition by building in a Boolean type and a test; the equation then
becomes [y = 0] = false. (This can also be handled using ﬁnite sums: see
Section 5.7 and Exercise 1 of Section 8.2.)

A colimit is similarly the categorical version of a quotient of a sum by an
equivalence relation. The quotient category constructed in Section 3.5 is an
example of a colimit in the category of categories.

This chapter discusses ﬁnite limits and colimits in detail, concentrating
on certain useful special cases. Inﬁnite limits and colimits are widely used
in mathematics, but they are conceptually similar to the ﬁnite case, and are
not described here.

Sections 9.1, 9.2 and 9.3 discuss limits. Sections 9.4 and 9.5 describe
colimits. Section 9.6 describes certain properties of sums which are desirable
in programming language semantics. Section 9.7 shows how uniﬁcation (as
used in logic programming) can be described as a kind of colimit. Section 9.8
describes some of the interaction between limits, colimits and factorizations.
Section 9.7 is not used in the rest of the book, and Section 9.8 is used only
in Chapter 16.

Limits and colimits are used in all the remaining chapters (but Chap-
ter 12 requires only pullbacks). In particular, they are used in Chapter 10
to describe more expressive types of sketches.

This chapter may be read right after Chapter 5, except that Section 9.7

requires familiarity with FP sketches (Section 7.1).

265

266

Limits and colimits

9.1 Equalizers

If S and T are sets and f, g : S −→ T are functions, it is a familiar fact that
we can form the subset Eq(f, g) ⊆ S consisting of all elements s ∈ S for
which f (s) = g(s). This concept can be made into a categorical concept by
changing it to a speciﬁcation which turns out to determine a subobject. We
will look more closely at the construction in Set to see how to make the
general categorical construction.

Suppose that j : Eq(f, g) −→ S is the inclusion function: j(u) = u for
u ∈ Eq(f, g). Let h : V −→ S be a function. Then h factors through j :
Eq(f, g) −→ S if and only if the image of the function h lies in the subset
Eq(f, g) (see 2.8.9). This is the key to the categorical speciﬁcation of Eq(f, g),
Deﬁnition 9.1.2 below.

9.1.1 Deﬁnition Two arrows f : A −→ B and g : A −→ B of a category
(having the same domain and the same codomain) are a parallel pair of
arrows. An arrow h with the property that f ◦ h = g ◦ h is said to equalize
f and g.

9.1.2 Deﬁnition Let C be a category and f, g : A −→ B be a parallel pair
of arrows. An equalizer of f and g is an object E together with an arrow
j : E −→ A with the following properties:

EQ–1 f ◦ j = g ◦ j.
EQ–2 For each arrow h : C −→ A such that f ◦ h = g ◦ h, there is an arrow

k : C −→ E, and only one, such that j ◦ k = h.

Frequently, E is referred to as an equalizer of f and g without referring

to j. Nevertheless, j is a crucial part of the data.

9.1.3 Examples of equalizers In Set, an equalizer E of the functions
(x, y) (cid:55)→ x2 + y2 and (x, y) (cid:55)→ 1 from R × R to R is the circle x2 + y2 = 1.
The arrow j : E −→ R × R is the inclusion.

Given a graph G , the inclusion of the set of loops in the graph is an
equalizer of the source and target functions. This equalizer will be empty if
the graph has no loops.

In a monoid M regarded as a category, any two elements of the monoid
form a parallel pair of arrows which may or may not have an equalizer. (See
Exercise 4.)

A theorem like Theorem 5.2.2 is true of equalizers as well.

9.1 Equalizers

267

9.1.4 Proposition If j : E −→ A and j(cid:48) : E(cid:48) −→ A are both equalizers of
f, g : A −→ B, then there is a unique isomorphism i : E −→ E(cid:48) for which
j(cid:48) ◦ i = j.

Proof. We give two proofs. The ﬁrst uses the concept of universal element.
Let C be the category containing the equalizers given. Let F : C op −→ Set be
the functor for which F (C) = {u : C −→ A | f ◦ u = g ◦ u}, the set of arrows
from C which equalize f and g. If h : D −→ C let F (h)(u) = u ◦ h. This makes
sense, because if u ∈ F (C), then f ◦ u ◦ h = g ◦ u ◦ h, so u ◦ h ∈ F (D). Note
that this makes F a subfunctor of the contravariant hom functor Hom(−, A)
as in Exercise 3 of Section 4.3. The deﬁnition of an equalizer of f and g can
be restated this way: an equalizer of f and g is an element j ∈ F (E) for
some object E such that for any u ∈ F (C) there is a unique arrow k : C
−→ E such that F (k)(j) = u. This means j is a universal element of F , so by
Corollary 4.5.13, any two equalizers j ∈ F (E) and j(cid:48) ∈ F (E(cid:48)) are isomorphic
by a unique arrow i : E −→ E(cid:48) such that F (i)(j(cid:48)) = j. That is, j = j(cid:48) ◦ i, as
required.

This method of constructing a functor of which the given limit is a uni-
versal element is a standard method in category theory. We have already
seen it used in the proof of Proposition 5.2.14 and in the discussion of the
uniqueness of eval in 6.1.7.

Here is a direct proof not using universal elements: the fact that f ◦
j(cid:48) = g ◦ j(cid:48) implies the existence of a unique arrow h : E(cid:48) −→ E such that
j(cid:48) = j ◦ h. The fact that f ◦ j = g ◦ j implies the existence of a unique arrow
h(cid:48) : E −→ E(cid:48) such that j = j(cid:48) ◦ h(cid:48). Then j ◦ h ◦ h(cid:48) = j(cid:48) ◦ h(cid:48) = j = j ◦ idE and
the uniqueness part of the deﬁnition of equalizer implies that h ◦ h(cid:48) = idE.
By symmetry, h(cid:48) ◦ h = idE(cid:48).

9.1.5 Proposition Let j : E −→ A be an equalizer of the pair of arrows
f, g : A −→ B. Then j is a monomorphism. Moreover, any two equalizers of
f and g belong to the same subobject of A.

Proof. To see that j is monic, suppose h, k : C −→ E with j ◦ h = j ◦ k = l.
Then f ◦ l = f ◦ j ◦ k = g ◦ j ◦ k so there is a unique arrow m : C −→ E with
j ◦ m = l. But both h and k are such arrows and so h = k.

Now suppose j and j(cid:48) are equalizers of f and g. In the notation of Propo-
sition 9.1.4, i and i−1 are the arrows required by the deﬁnition of subobject
in 2.8.11, since j(cid:48) ◦ i = j and j ◦ i−1 = j(cid:48).

9.1.6 More generally, if f1, . . . , fn are all arrows from A to B, then an
object E together with an arrow j : E −→ A is an equalizer of f1, . . . , fn
if it has the property that an arbitrary arrow h : C −→ A factors uniquely

268

Limits and colimits

through j if and only if f1 ◦ h = · · · = fn ◦ h. Having equalizers of parallel
pairs implies having equalizers of all ﬁnite lists (Exercise 2).

9.1.7 Regular monomorphisms A monomorphism e : S −→ T in a cat-
egory is regular if e is an equalizer of a pair of arrows. Monomorphisms in
Set are regular (Exercise 5) but not all monomorphisms in Cat are regular
(Exercise 6).

9.1.8 Proposition An arrow in a category that is both an epimorphism
and a regular monomorphism is an isomorphism.

Proof. Let f : A −→ B be both an epimorphism and an equalizer of g, h : B
−→ C. Since g ◦ f = h ◦ f and f is epi, g = h. Then g ◦ idB = h ◦ idB so there
is a k : B −→ A such that f ◦ k = idB. But then f ◦ k ◦ f = f = f ◦ idA. But
f being mono can be cancelled from the left to conclude that k ◦ f = idA.

9.1.9 Exercises

1. Recall that an arrow f : A −→ B in a category is a split monomorphism
if there is a g : B −→ A with g ◦ f = idA. Show that a split monomorphism
is regular.

2. Show that a category with equalizers of all parallel pairs of arrows has
equalizers of every ﬁnite list f1, . . . , fn : A −→ B of arrows.
3.† Prove that in the category of monoids every pair of parallel arrows has
an equalizer.

4. a. Prove that if M is a free monoid, then in C(M ) no two diﬀerent
elements have an equalizer.

b. Prove the same statement for ﬁnite monoids. (Hint: See Exercise 3 of

Section 2.9.)

5. Prove that every monomorphism in Set is regular.

6. Suppose that A and B are categories with two objects and whose only
nonidentity arrows are as shown:

C

D(cid:45)u

A

C

(cid:190)

(cid:45)u
v

D

B

Show that the inclusion functor of A into B is an epimorphism in Cat.
Conclude it cannot be a regular monomorphism. (Hints: The arrows u and
v are inverse to each other. Use Proposition 9.1.8.)

9.2 The general concept of limit

9.2 The general concept of limit

269

Products and equalizers are both examples of the general concept of limit.

9.2.1 Deﬁnition Let G be a graph and C be a category. Let D : G −→ C
be a diagram in C with shape G . A cone with base D is an object C of C
together with a family {pa} of arrows of C indexed by the nodes of G , such
that pa : C −→ Da for each node a of G . The arrow pa is the component of
the cone at a.

The cone is commutative if for any arrow s : a −→ b of G , the diagram

C

(cid:161)

(cid:64)

Ds

pb
(cid:64)
(cid:64)(cid:82)
Db(cid:45)

pa
(cid:161)(cid:170)

(cid:161)

Da

commutes. Note: The diagram D is not assumed to commute.

Such a diagram will also be termed a commutative cone over D (or to D
or with base D) with vertex C. We will write it as {pa} : C −→ D or simply
p : C −→ D. It is clear that if p : C −→ D is a cone over D and f : C(cid:48) −→ C
is an arrow in C , then there is a cone p ◦ f : C(cid:48) −→ D whose component at
a is pa ◦ f . Moreover p ◦ f is commutative if p is. Note that a cone over a
discrete diagram (see 5.1.3) is vacuously commutative.

9.2.2 Deﬁnition If p(cid:48) : C(cid:48) −→ D and p : C −→ D are cones, a morphism
from p(cid:48) to p is an arrow f : C(cid:48) −→ C such that for each node a of G , the
diagram

C(cid:48)

(cid:64)
p(cid:48)
a

(cid:64)

(cid:64)(cid:82)

f

Da

C(cid:45)
(cid:161)
pa

(cid:161)

(cid:161)(cid:170)

commutes.

9.2.3 Deﬁnition A commutative cone over the diagram D is called uni-
versal if every other commutative cone over the same diagram has a unique
arrow to it. A universal cone, if such exists, is called a limit of the diagram
D.

9.2.4 It is worth spelling out in some detail the meaning of a limit. To say
that p : C −→ D is a limit means that there is given a family pa : C −→ Da,
indexed by the nodes of G , for which

L–1 Whenever s : a −→ b is an arrow of G , then Ds ◦ pa = pb.

270

Limits and colimits

L–2 If p(cid:48) : C(cid:48) −→ D is any other such family with the property that Ds ◦
b for every s : a −→ b in G , then there is one and only one arrow

p(cid:48)
a = p(cid:48)
f : C(cid:48) −→ C such that for each node a of G , pa ◦ f = p(cid:48)
a.

9.2.5 Examples A limit cone over a ﬁnite discrete diagram is a product
cone: here, L–1 and the commutativity condition Ds ◦ p(cid:48)
b in L–2 are
vacuous.

a = p(cid:48)

Equalizers are also limits. Let f, g : A −→ B be parallel arrows in a cate-

gory. An equalizer e : E −→ A is part of a cone

(cid:161)

e
(cid:161)
(cid:161)(cid:170)

A

E

f
g

(cid:64)

u
(cid:64)
(cid:64)(cid:82)(cid:45)
(cid:45)

B

(9.1)

where u = f ◦ e = g ◦ e. This cone is commutative, and it is a limit cone if
and only if e is an equalizer of f and g. Since u is determined uniquely by f
and e (or by g and e), it was not necessary to mention it in Deﬁnition 9.1.2.

9.2.6 Equivalent deﬁnitions of limit There are two more equivalent
ways to deﬁne limits. Let D : G −→ C be a diagram. We deﬁne the category
cone(D) as follows. An object of this category is a commutative cone {pi : C
−→ Di} and an arrow is a morphism of cones (Deﬁnition 9.2.2). It is evident
that the identity is a morphism and that the composite of two morphisms is
another one. A terminal object in cone(D), if one exists, is a commutative
cone over D to which every other commutative cone over D has a unique
morphism. Thus we have shown that the existence of a limit is equivalent to
the existence of a terminal object of cone(D).

The second equivalent construction of limits associates to D a functor
we call cone(−, D) : C op −→ Set. For an object C of C , cone(C, D) is the set
of commutative cones p : C −→ D. If f : C(cid:48) −→ C, cone(f, D) : cone(C, D)
−→ cone(C(cid:48), D) is deﬁned by cone(f, D)(p) = p ◦ f . It is straightforward to
verify that this is a functor. A universal element of this functor is an object
C and an element p ∈ cone(C, D) such that for any C(cid:48) and any element p(cid:48) ∈
cone(C(cid:48), D) there is a unique arrow f : C(cid:48) −→ C such that p ◦ f = p(cid:48). But this
is just the deﬁnition of a limit cone. (Compare the proof of Proposition 9.1.4.)

We have now sketched the proof of the following.

9.2.7 Theorem The following three are equivalent for a diagram D in a
category C :

(i) a limit of D;
(ii) a terminal object of cone(D);

9.2 The general concept of limit

271

(iii) a universal element of the functor cone(−, D).

In particular, one can see products and equalizers as terminal objects or
as universal elements. One immediate consequence of this, in light of 4.5.13,
is that a limit of a diagram is characterized uniquely up to a unique iso-
morphism in the same way that a product is.

9.2.8 Theorem Let D be a diagram and p : C −→ D and p(cid:48) : C(cid:48) −→ D
limits. Then there is a unique arrow i : C −→ C(cid:48) such that for every node a
of the shape graph of D, p(cid:48)

a ◦ i = pa and i is an isomorphism.

9.2.9 Deﬁnition A category is said to have all limits or to be complete
if every diagram has a limit. It is said to have all ﬁnite limits or to be
ﬁnitely complete if every diagram whose domain is a ﬁnite graph has a
limit.

The following theorem gives a useful criterion for the existence of all
limits or all ﬁnite limits. Another way of getting all ﬁnite limits is given by
Proposition 9.3.7.

9.2.10 Theorem Let C be a category in which every set (respectively, ev-
ery ﬁnite set) of objects has a product and every parallel pair of arrows has
an equalizer. Then every diagram (respectively, every ﬁnite diagram) in C
has a limit.

The proof of the main claim is given in Exercise 3. The case for ﬁnite
limits is exactly the same, specialized to that case. As an immediate corollary,
using Exercise 1.c of Section 5.3, we have the following.

9.2.11 Corollary A category C with the following properties

(i) C has a terminal object;
(ii) every pair of objects has a product; and
(iii) every parallel pair of arrows has an equalizer

has all ﬁnite limits.

9.2.12 Deﬁnition A functor F : C −→ D preserves limits if it takes
every limit cone in C to a limit cone in D. It preserves ﬁnite limits if
it takes every limit cone over a graph with a ﬁnite diagram in C to a limit
cone in D.

It follows from Corollary 9.2.11 that a functor that preserves terminal
objects, products of pairs of objects, and equalizers of parallel pairs of arrows
preserves all ﬁnite limits.

272

Limits and colimits

9.2.13 Exercises

1. Prove that Diagram (9.1) is a limit cone if and only if e is an equalizer of
f and g.

2. Let f : S −→ T be a set function. Construct limits of each of these dia-
grams in Set. In (c) the arrows are the unique functions to the terminal
object.

T(cid:45)f

S

T(cid:45)f

(cid:190)f

S

S

S

1(cid:45)

(cid:190)

S

(a)

(b)

(c)

3. In this exercise, C is a category in which every set of objects has a product
and every pair of arrows with the same source and target has an equalizer.
The purpose of this exercise is to prove Theorem 9.2.10.

a. Suppose that I is a graph that may have an arbitrary set of nodes,
but just one nonidentity arrow a : j −→ k. Show that for any D : I −→ C ,
an equalizer

E −→

(cid:89)

i∈I

Di

Da ◦ projj
−−−−−−−−−→
−−−−−−−−−→
projk

Dk

is a limit of D.

b. Suppose that I has just two nonidentity arrows a : j −→ k and b : l
Di
Di −→ Dm and s2 =
Di −→ Dk × Dm and s = (cid:104)s1, s2(cid:105) :

−→ m (no assumption of distinctness is made). Let r1 = Da ◦ projj :
−→ Dk, s1 = projk :
(cid:81)
projm :
(cid:81)

Di −→ Dk, r2 = Db ◦ projl :

Di −→ Dm. Let r = (cid:104)r1, r2(cid:105) :

(cid:81)

(cid:81)

(cid:81)

(cid:81)

Di −→ Dk × Dm. Show that if

E −→

(cid:89)

Di

r
−−→−−→
s

Dk × Dm

is an equalizer, then E is a limit of D.

(cid:81)

Di, taken over the objects of I and B =

c. Let I be an arbitrary graph and D : I −→ C a diagram in C . Let
(D(target a)), the product
A =
taken over the set of all arrows of I . Let r : A −→ B be such that proja ◦
r = Da ◦ projsource(a) and s : A −→ B be such that proja ◦ s = projtarget(a).
Let

(cid:81)

E −→ A

r
−−→−−→
s

B

be an equalizer. Then E is a limit of D.

9.3 Pullbacks

9.3 Pullbacks

273

Here is another example of a ﬁnite limit that will be important to us. Con-
sider an object P and arrows p1 : P −→ A and p2 : P −→ B such that the
diagram

A(cid:45)p1

P

p2

f

(9.2)

(cid:63)
B

(cid:63)

C(cid:45)

g

commutes. This does not appear directly to be a cone, because there is no
arrow from the vertex P to C. It is understood to be a commutative cone
with the arrow from P to C being the composite f ◦ p1, which by deﬁnition
is the same as the composite g ◦ p2. It is common to omit such forced arrows
in a cone. (Compare the discussion after Diagram (9.1).) It is more cone-like
if we redraw the diagram as

P

(cid:161)

(cid:64)

(cid:161)

(cid:161)

(cid:64)

(cid:64)

f ◦ p1 = g ◦ p2

(cid:64)

p2
(cid:64)

(cid:64)

(cid:63)

C(cid:45)

(cid:190)

(cid:64)

(cid:64)(cid:82)

B

g

(cid:161)

p1
(cid:161)

(cid:161)

(cid:161)

(cid:161)(cid:170)

A

f

However, the square shape of (9.2) is standard.

If this commutative cone is universal, then we say that P together with
the arrows p1 and p2 is a pullback or ﬁber product of the pair. We also
say that p2 is the pullback of f along g, and that (9.2) is a pullback
diagram. We often write P = A ×C B, although this notation omits the
arrows which are as important as the object C.

9.3.1 Example In Set, if f : S −→ T and g : U −→ T are functions, then
the pullback

S(cid:45)p1

P

p2

(cid:63)
U

(cid:63)

T(cid:45)

g

f

(9.3)

274

Limits and colimits

is constructed by setting

P = {(s, u) | f (s) = g(u)}

with p1(s, u) = s and p2(s, u) = u.

In one way this example is characteristic of pullbacks in any category
with products: in any such category, P is a subobject of S × U (Exercise 4).

9.3.2 Example The inverse image of a function is a special case of a pull-
back. Suppose g : S −→ T is a set function and A ⊆ T . Let i : A −→ T be the
inclusion. Let g−1(A) = {x ∈ S | g(x) ∈ A} be the inverse image of A, j be
its inclusion in S, and h be the restriction of g to g−1(A). Then the following
is a pullback diagram.

g−1(A)

A(cid:45)h

j

(cid:63)
S

i
(cid:63)

T(cid:45)

g

(9.4)

Observe that Example 9.3.1 gives a general construction for pullbacks in
sets, and the present example gives a construction for a special type of pull-
back, but this construction is not a special case of the construction in 9.3.1.
By Theorem 9.2.8, there must be a unique function u : {(s, a) | g(s) = a}
−→ g−1(A) for which g(j(u(s, a))) = i(h(u(s, a))). By the deﬁnitions of the
functions involved, u(s, a) must be s.

The reader may wish to know the origin of the term ‘ﬁber product’. Consider
a function f : S −→ T . Of the many ways to think of a function, one is as
determining a partition of S indexed by the elements of T . (See 2.6.11.) For
t ∈ T , let

St = f −1(t) = {s ∈ S | f (s) = t}
This is a family of disjoint subsets of S (some of which may be empty) whose
union is all of S. This is sometimes described as a ﬁbration of S and St is
called the ﬁber over t. Now if S −→ T and U −→ T are two arrows and S ×T U
is a pullback, then it is not hard to see that

(cid:91)

S ×T U =

{St × Ut | t ∈ T }

In other words, S ×T U is the ﬁbered set whose ﬁber over any t ∈ T is the
product of the ﬁbers. This is the origin of the term and of the notation. We
will not use the term in this book, but the notation has become standard and
is too useful to abandon. Fibrations can be constructed for categories as well
as sets; they are considered in Section 12.1.

Pullbacks can be used to characterize monomorphisms in a category.

9.3.3 Theorem These three conditions are equivalent for any arrow f : A
−→ B in a category C :

9.3 Pullbacks

275

(a) f is monic.
(b) The diagram

(cid:161)

A

f

(cid:64)

(cid:63)
B(cid:45)

(cid:190)

(cid:64)

id
(cid:64)
(cid:64)(cid:82)

f

A

(cid:161)

id
(cid:161)
(cid:161)(cid:170)

A

f

is a limit cone.

(c) There is an object P and an arrow g : P −→ A for which

P

(cid:161)

(cid:64)

(cid:161)

f ◦ g

(cid:63)
B(cid:45)

(cid:190)

g
(cid:161)

(cid:161)(cid:170)

A

f

is a limit cone.

(cid:64)

g
(cid:64)

(cid:64)(cid:82)

A

f

(The operative condition in (c) is that the same arrow g appears on both

slant lines.)

Another connection between pullbacks and monomorphisms is given by

the following.

9.3.4 Proposition In Diagram (9.2), if the arrow f is monic, then so is
p2.

This proposition is summed up by saying, ‘A pullback of a monic is a

monic.’ Contrast it with the situation for epis given in Exercises 7 and 8.

The proofs of Theorem 9.3.3 and Proposition 9.3.4 are left as exercises.

9.3.5 Weakest precondition as pullback A widely used approach to
program veriﬁcation is to attach preconditions and postconditions to pro-
gram fragments. An example is

1 ◦ {X < 3}
2 ◦ X := X + 1;
3 ◦ {X < 24}

where X is an integer variable.

(9.5)

276

Limits and colimits

Statement 1 is called a precondition and statement 3 is a postcondi-
tion. The whole expression (9.5) is an assertion about the program: if the
precondition is true before the program fragment is executed, the postcon-
dition must be true afterward.

Clearly (9.5) is correct but a stronger assertion can be made. For the
given postcondition, the weakest possible precondition is {X < 23}. In a
very general setting, there is a weakest precondition for every postcondition.
This can be placed in a categorical setting. Let D be the set of possible
inputs and E be the set of possible outputs. Then the program fragment,
provided it is deterministic and terminating, can be viewed as an arrow
f : D −→ E. Any condition C on a set X can be identiﬁed with the subset
X0 = {x | x satisﬁes C}. In particular, the postcondition is a subset S ⊆ E
and the weakest precondition for that postcondition is the inverse image
f −1(S), which is the unique subobject of D for which

(cid:45)
f −1(S)

D(cid:45)

(cid:63)
(cid:45)
S

(cid:63)
E(cid:45)

is a pullback. In the example, f (x) = x + 1, S = {x | x < 24} and f −1(S) =
{x | x + 1 < 24} = {x | x < 23}.

This is easily checked in the case of Set and is a plausible point of view

for other categories representing data and program fragments.

In the general case, one would expect that an assertion would be some
special kind of subobject. For example, Manes [1986] requires them to be
‘complemented’, a concept to be discussed in 9.6.2 below, and Wagner [1987]
requires them to be regular (see 9.1.7). Naturally, if one requires that asser-
tions be subobjects with a certain property, one would want to work in a
category in which pullbacks of such subobjects also had the property. In a
topos (toposes will be discussed in Chapter 15), for example, pullbacks of
complemented subobjects are complemented, and all monomorphisms are
regular.

9.3.6 Constructing all ﬁnite limits revisited Corollary 9.2.11 described
a class of limits whose existence guarantees the existence of all ﬁnite limits.
A similar construction is possible for pullbacks.

9.3.7 Proposition A category that has a terminal object and all pullbacks
has all ﬁnite limits.

The proof is left as an exercise.

9.4 Coequalizers

277

9.3.8 Exercises

1. Prove that (9.4) is a pullback diagram.

2. Prove Theorem 9.3.3.

3. Prove Proposition 9.3.4.

4. Show that if Diagram (9.3) is a pullback in any category with products,
then (cid:104)p1, p2(cid:105) : P −→ S × U is monic. (Here p1 and p2 refer to the arrows so
labeled in the diagram.)

5. Show that equalizers can be constructed out of products and pullbacks.
(Hint: Try to work it out in the category of sets and then do it in general
categories.)

6. Prove Proposition 9.3.7.

7. Prove that in Set if f in Diagram (9.2) is an epimorphism, then so is p2.
(One says that a pullback of an epimorphism is an epimorphism in Set.)
8.† Give an example of a category with an epimorphism whose pullback along
at least one arrow is not an epimorphism.

9. Prove that a pullback of a split epimorphism is a split epimorphism in
any category.

10. Show that if the left and right squares below are pullbacks then so is
the outer rectangle. What does this say about weakest preconditions?

P

Q(cid:45)

B(cid:45)

(cid:63)
C

(cid:63)
D(cid:45)

(cid:63)
E(cid:45)

9.4 Coequalizers

In 9.1.2 we introduced the notion of equalizer. The dual notion is called
coequalizer. Explicitly, consider f, g : A −→−→ B. An arrow h : B −→ C is called
a coequalizer of f and g provided h ◦ f = h ◦ g and for any arrow k : B
−→ D for which k ◦ f = k ◦ g, there is a unique arrow l : C −→ D such that
l ◦ h = k.

The way to think about the coequalizer of f and g is as the quotient
object made by forcing f and g to be equal. In the category of sets, this
observation becomes the construction that follows.

278

Limits and colimits

9.4.1 Coequalizers in Set Let f, g : S −→−→ T be a pair of arrows in the
category of sets. The conditions a coequalizer h : T −→ U must satisfy are
that h ◦ f = h ◦ g and that given any arrow k : T −→ V , the equation k ◦ f =
k ◦ g implies the existence of a unique arrow l : U −→ V such that l ◦ h = k.
(If such an arrow l exists, then necessarily k ◦ f = k ◦ g.)

The pair f and g determine a relation R ⊆ T × T which consists of

{(f (s), g(s)) | s ∈ S}

The equation k ◦ f = k ◦ g is equivalent to the statement that k(t1) = k(t2)
for all (t1, t2) ∈ R.

In general R is not an equivalence relation, but it can be completed to
one by forming the reﬂexive, symmetric and transitive closures of R in that
order. The reﬂexive, symmetric closure is the union R1 = R ∪ ∆ ∪ Rop where
∆ = {(t, t) | t ∈ T } and Rop = {(t2, t1) | (t1, t2) ∈ R}. If we inductively deﬁne
Ri+1 to be the set

{(t1, t2) | ∃t ∈ T ((t1, t) ∈ R1 and (t, t2) ∈ Ri)}

for each i ∈ N and deﬁne (cid:101)R =
and is the least equivalence relation containing R.

Rn, then (cid:101)R is the transitive closure of R1

(cid:83)

When S and T are ﬁnite, the least equivalence relation of the previous
paragraph can be computed eﬃciently by Warshall’s Algorithm ([Sedgewick,
1983], p. 425).

Let U be the set of equivalence classes modulo the equivalence relation
(cid:101)R and let h : T −→ U be the function that sends an element of T to the class
that contains that element.

9.4.2 Proposition The arrow h is a coequalizer of f and g.
Proof. Since R ⊆ (cid:101)R, the fact that h(t1) = h(t2) for all (t1, t2) ∈ (cid:101)R implies, in
particular, that the same equation is satisﬁed for all (t1, t2) ∈ R; this means
that for all s ∈ S, h(f (s)) = h(g(s)), so that h ◦ f = h ◦ g.

Now let k : T −→ V satisfy k ◦ f = k ◦ g. We claim that for (t1, t2) ∈ (cid:101)R,
k(t1) = k(t2). In fact, this is true for (t1, t2) ∈ R. It is certainly true for
t1 = t2, i.e. (t1, t2) ∈ ∆ implies that k(t1) = k(t2). Since k(t1) = k(t2) implies
that k(t2) = k(t1), we now know that the assertion is true for (t1, t2) ∈ R1.
Since k(t1) = k(t2) and k(t2) = k(t3) imply k(t1) = k(t3), one may show by
induction that the assertion is true for all the Rn and hence for (cid:101)R. This
shows that k is constant on equivalence classes and hence induces a function
l : U −→ V such that l ◦ h = k. Since h is surjective, l is unique.

9.4 Coequalizers

279

9.4.3 Regular epimorphisms
In Proposition 9.1.5, it is asserted that all
equalizers are monomorphisms. The dual is of course also true; all coequal-
izers are epimorphisms. The converse is not true; not every epimorphism is
a coequalizer of some pair of arrows. For example, in the category of mon-
oids, the inclusion of the nonnegative integers into the set of all integers is
an epimorphism but is not the coequalizer of any pair of arrows. Those epi-
morphisms that are the coequalizer of some pair of arrows into their domain
are special and this is marked by giving them a special name: they are called
regular epimorphisms.

In the category of sets, every epimorphism is regular (Exercise 2). Because
of Exercise 7 of Section 9.3, it follows that in the category of sets, a pullback
of a regular epi is regular.

A category is called a regular category if it has ﬁnite limits, if every
parallel pair of arrows has a coequalizer, and if the arrow opposite a regular
epimorphism in a pullback diagram is a regular epimorphism. A functor
between regular categories is called a regular functor if it preserves ﬁnite
limits and regular epis.

It is an old theorem (stated in diﬀerent language) that all categories of models
of FP sketches, in other words, all varieties of multisorted algebraic structures,
are regular ([Barr and Wells, 1985], Theorem 1 of Section 8.4). Because of
such examples, regular categories have seen considerable theoretical study, and
regular epimorphisms have played a larger role in category theory than regular
monos have.

9.4.4 Exercises

1. Show that any coequalizer is an epimorphism.

2. Prove that an epimorphism in the category of sets is regular. (Hint: Its
image is isomorphic to its quotient.)

3. Let N denote the monoid of natural numbers on addition and Z the
monoid of integers on addition. Show that the inclusion function is an epi-
morphism (in the category of monoids) which is not regular.
4.† Prove that in the category of monoids an epimorphism f is regular if and
only if U (f ) is surjective, where U is the underlying functor to Set.

5. If f : A −→ B is an arrow in a category, a kernel pair

K

d 0
−−−→−−−→
d 1

A

280

Limits and colimits

is a limit

K

A(cid:45)d 0

d 1

f

(cid:63)
A

(cid:63)
B(cid:45)

f
Show that if f has a kernel pair d 0, d 1, then f is a regular epimorphism if
and only if f is the coequalizer of its kernel pair.

9.5 Cocones

Just as there is a general notion of limit of which products and equalizers
are special cases, so there is a general notion of colimit.

9.5.1 Deﬁnition A cocone is a cone in the dual graph. Spelling the deﬁ-
nition out, it is a diagram D : G0 −→ G , a node g of G together with a family
ua : Da −→ g of arrows indexed by the objects of G0. The diagram is called
the base of the cocone. If the diagram is discrete, it is called a discrete
cocone.

A cocone in a category is called commutative if it satisﬁes the dual
condition to that of commutative cone. Explicitly, if the diagram is D : G
−→ C and the cone is {ua : Da −→ C | a ∈ Ob(G )}, then what is required is
that for each arrow s : a −→ b of G , ub ◦ Ds = ua. The commutative cocone is
called a colimit cocone if it has a unique arrow to every other commutative
cocone with the same base.

9.5.2 Cocompleteness A category has all colimits or is cocomplete
if every diagram in the category has a colimit. It has ﬁnite colimits or is
ﬁnitely cocomplete if every diagram with a ﬁnite graph has a colimit.

Categories of algebraic structures are complete and cocomplete. If we
disallowed the empty semigroup (see 2.7.17) we would have to say that the
category of semigroups is ‘complete and cocomplete except that it does not
have an initial object’. We would also have to say that the intersection of
any set of subsemigroups of a semigroup is either a subsemigroup or empty.

9.5.3 Pushouts For example, dual to the notion of pullback is that of
pushout. In detail, a commutative square

9.5 Cocones

281

C

g

A(cid:45)f

q1

(cid:63)
B

(cid:63)
Q(cid:45)

q2

(9.6)

is called a pushout if for any object R and any pair of arrows r1 : A −→ R
and r2 : B −→ R for which r1 ◦ f = r2 ◦ g there is a unique arrow r : Q −→ R
such that r ◦ qi = ri, i = 1, 2.

9.5.4 Pushouts as amalgamations If the eﬀect of coequalizers is to
force identiﬁcations, that of pushouts is to form what are called amalga-
mated sums. We illustrate this with examples.

First, consider the case of a set S and three subsets S0, S1 and S2 with

S0 = S1 ∩ S2 and S = S1 ∪ S2. Then the diagram

S0

S1(cid:45)

(cid:63)
S2

(cid:63)

S(cid:45)

with all arrows inclusion, is a pushout. (It is a pullback as well; such diagrams
are often referred to as Doolittle diagrams.) The deﬁnition of pushout
translates to the obvious fact that if one is given functions f1 : S1 −→ T and
f2 : S2 −→ T and f1|S0 = f2|S0, then there is a unique function f : S −→ T
with f |S1 = f1 and f |S2 = f2.

Now consider a slightly more general situation. We begin with sets S0, S1
and S2 and functions g1 : S0 −→ S1 and g2 : S0 −→ S2. If g1 and g2 are
injections, then, up to isomorphism, this may be viewed as the same as
the previous example. Of course, one cannot then form the union of S1
and S2, but rather ﬁrst the disjoint sum and then, for s ∈ S0, identify the
element g1(s) ∈ S1 with g2(s) ∈ S2. In this case, the pushout is called an
amalgamated sum of S1 and S2.

More generally, the gi might not be injective and then the amalgamation
might identify two elements of S1 or of S2, but the basic idea is the same;
pushouts are the way you identify part of one object with a part of another.

282

Limits and colimits

9.5.5 Equations, equalizers and coequalizers One way of thinking
about an equalizer is as the largest subobject on which an equation or set of
equations is true. A coequalizer, by contrast, is the least destructive identi-
ﬁcation necessary to force an equation to be true on the equivalence classes.
Here is an instructive example. There are two ways of deﬁning the rational
numbers. They both begin with the set Z × N+ of pairs of integers (a, b) for
which b > 0. For the purpose of this illustration, we will write (a/b) instead
of (a, b). In the ﬁrst, more familiar, construction, we identify (a/b) with (c/d)
when a ∗ d = b ∗ c. One way of describing this is as the coequalizer of two
arrows

T −→−→ Z × N+
where T is the set of all (a, b, c, d) ∈ Z × N+ × Z × N+ such that a ∗ d = b ∗ c
and the ﬁrst arrow sends (a, b, c, d) to (a/b) while the second sends it to (c/d).
The eﬀect of the coequalizer is to identify (a/b) with (c/d) when a ∗ d = b ∗ c.
The second way to deﬁne the rationals is the set of pairs that are relatively
prime (that is, in lowest terms). This can be realized as an equalizer as
follows. Let gcd : Z × N+ −→ N+ take a pair of numbers to their positive
greatest common divisor. Let 1 ◦ (cid:104)(cid:105) : Z × N+ −→ N+ denote the function
that is constantly 1. Then an equalizer of gcd and 1 ◦ (cid:104)(cid:105) is exactly the set of
relatively prime pairs.

9.5.6 Exercises

1. Show that in any category, if both squares in

A

g

(cid:63)
C

B(cid:45)f

h
(cid:63)
D(cid:45)

k

A(cid:48)

B(cid:48)(cid:45)f (cid:48)

g(cid:48)

(cid:63)
C(cid:48)

h(cid:48)
(cid:63)
D(cid:48)(cid:45)

k(cid:48)

are pushouts, then so is

A + A(cid:48)

f + f (cid:48)

(cid:45)

B + B(cid:48)

g + g(cid:48)

(cid:63)
C + C(cid:48)

h + h(cid:48)
(cid:63)
D + D(cid:48)

(cid:45)

k + k(cid:48)

9.5 Cocones

283

2. Let A, B, C be sets and f : C −→ A, e : C −→ B functions with e injective.
Let e(C) denote the image of e and X = B − e(C) the complement of the
image in B. Let i : A −→ A + X and j : X −→ A + X be the canonical
injections.

a. Show that the diagram below is a pushout.

C

f

B(cid:45)e

=e(C)+X

i ◦ f ◦ e−1 + j
(cid:63)
A + X

(cid:63)
A

(cid:45)

i

b. Conclude that in Set the pushout of a monomorphism is a mono-

morphism.

3. a. Show that Z can be constructed from N as the coequalizer of two
arrows g, h : N×N×N −→ N×N, deﬁned by g(a, b, c) = (b, c) and h(a, b, c) =
(a + b, a + c). (Hint: Addition is coordinatewise; 1 and −1 are the classes
containing (1, 0) and (0, 1), respectively.)

b. Show that the integers can also be constructed as a subset of N × N
consisting of all (n, m) such that m = 0 or n = 0. The sum is the usual sum
followed by the application of the function r(n, m) = (n ◦− m, m ◦− n), where
◦− is subtraction at 0. This function is the additive analog of reduction to
lowest terms by dividing by the greatest common divisor.
4. Let f, g : N+ × Z × N+ −→ Z × N+ be deﬁned by f (a, b, c) = (b, c) and
g(a, b, c) = (ab, ac). Show that the coequalizer of f and g can also be thought
of as the rational numbers (see 9.5.5).

5. Show that in the category of sets, if both squares in
B(cid:48)(cid:45)f (cid:48)
B(cid:45)f

A(cid:48)

A

g

(cid:63)
C

h
(cid:63)
D(cid:45)

k

g(cid:48)

(cid:63)
C(cid:48)

h(cid:48)
(cid:63)
D(cid:48)(cid:45)

k(cid:48)

are pullbacks, then so is

A + A(cid:48)

f + f (cid:48)

(cid:45)

B + B(cid:48)

g + g(cid:48)

(cid:63)
C + C(cid:48)

h + h(cid:48)
(cid:63)
D + D(cid:48)

(cid:45)

k + k(cid:48)

284

Limits and colimits

6.† a. Let 2 be the category with two objects and one nonidentity arrow be-
tween them and N be the category with one object and the natural numbers
as its set of arrows, with 0 the identity arrow and n ◦ m = n + m. Show that
the functor q : 2 −→ N that takes the nonidentity arrow of 2 to 1 is a regular
epi, even though it is not surjective on arrows. Note that this shows that the
underlying arrow functor from Cat to Set does not preserve coequalizers,
since coequalizers in Set are surjective.

b. Let t : N −→ N be the functor that assigns to the integer n the number
2n. Let 1 + 1 be the category with two objects and two identity arrows and
none other. Show that there is a pullback diagram

1 + 1

N(cid:45)

t
(cid:63)
N(cid:45)

(cid:63)
2

q

and that the top arrow is not a regular epi.

c. Let 3 be the category with three objects, say the numbers 0, 1 and
2 and three nonidentity arrows, one from 0 to 1, one from 1 to 2 and the
composite of them from 0 to 2. Let C be the category with four objects we
will call 0, 1, 1(cid:48) and 2 and three nonidentity arrows, one from 0 to 1, one
from 1(cid:48) to 2 and one from 0 to 2. Show that the functor F : C −→ 3 pictured
in Diagram (9.7) is not a regular epi, even though it is surjective on both
objects and arrows.

g(cid:64)
(cid:64)
(cid:64)(cid:82)
(cid:45)

2

(cid:161)(cid:181)

(cid:161)

f
(cid:161)

1

1(cid:48)

h

F
(cid:63)

1

(9.7)

(cid:161)(cid:181)

(cid:161)

f
(cid:161)

(cid:161)

(cid:64)

(cid:64)

g
(cid:64)

(cid:64)(cid:82)
2(cid:45)

g ◦ f

0

0

d. Show that a regular epi in Cat is stable, that is every pullback of it is
a regular epi, if and only if it induces a surjection on the set of composable
pairs of arrows.

9.6 More about sums

285

9.6 More about sums

Sums in the category of sets have special properties they do not have in most
other categories, including most categories of mathematical structures. Two
of these special properties, that sums are disjoint and that they are univer-
sal, are widely assumed in the study of categories suitable for programming
language semantics. They are deﬁned in this section.

9.6.1 Disjoint sums
Suppose that A and B are two objects in a category
with an initial object 0 and a sum A + B. Then we have a commutative
diagram

0

(cid:161)

(cid:64)

A

(cid:161)

(cid:161)(cid:170)

(cid:64)

(cid:64)

(cid:64)(cid:82)

(cid:161)

B

(9.8)

(cid:64)

(cid:161)

(cid:161)(cid:170)
(cid:64)(cid:82)
A + B

If this diagram is a pullback, and the canonical injections A −→ A + B and
B −→ A + B are monic, then the sum is said to be disjoint. It is easy to see
that sums in the category of sets are disjoint. In fact, that is essentially how
they are deﬁned.

9.6.2 Diagram (9.8) is a pushout in any case. If a diagram

0

(cid:161)

(cid:64)

(cid:161)

(cid:161)(cid:170)

A

(cid:64)

(cid:64)(cid:82)

B

(9.9)

(cid:64)
i

(cid:64)

(cid:64)(cid:82)

(cid:161)
j

(cid:161)

(cid:161)(cid:170)

C

is both a pullback and a pushout, then C is the sum of A and B with the
arrows i and j as canonical injections. If i and j are monic, then A and B
are subobjects of C and the sum is disjoint. In this situation B is said to be
the complement of A in C (and conversely), and A and B are said to be
complemented subobjects.

286

Limits and colimits

9.6.3 Example In Set, every subobject is complemented: the comple-
ment is what is usually meant by complement.

9.6.4 Example
In Mon there are many subobjects which are noncomple-
mented; for example, the set of even integers is a submonoid of the monoid
of all integers on addition, but it has no complement. Its set-theoretic com-
plement, the set of odd integers, is not a submonoid: it does not contain the
identity element (zero) and the sum of two odd integers is never odd. Even
if its set-theoretic complement were a submonoid (impossible since only one
of the two could contain the unit element), it still would not necessarily be
the complement in the category.

A semigroup can have two subsemigroups whose underlying sets are com-
plements but which is not the sum in the category of semigroups of those
two subsemigroups. See Exercise 5.

9.6.5 Computable subsets More interesting from a computational point
of view is the fact that some computable subsets of the natural numbers do
not have computable complements. That is, there are subsets A of N with
both these properties:

(a) There is an algorithm that halts on n if and only if n ∈ A.
(b) There is no algorithm to determine if an arbitrary element n ∈ A.

A set A is said to be computable or recursively enumerable if it
has property (a). If A also has property (b) then the complement of A
cannot be computable. (See [Lewis and Papadimitriou, 1981].) Thus in the
category of computable subsets of the natural numbers and computable maps
between them, there are noncomplemented subobjects. An expression such
as If n In A Then Do P should have a computable meaning only if A is
complemented.

The category of Boolean algebras (deﬁned in 5.7.5) is an example of a category
in which sums are not disjoint. Although many books do not allow the one-
element Boolean algebra, we do. It is the terminal Boolean algebra. In the
category it is characterized by the fact that it admits no arrows to any Boolean
algebra but itself. This is because in this algebra true = false and an arrow
between Boolean algebras must take true to true and false to false. That being
the case, the only possible sum of 1 and 1 is 1 itself since the sum must admit an
arrow from each constituent. From this it is clear that the pullback in question
is 1 which is not initial (actually 2 is initial).

9.6.6 Universal sums Finite sums in a category are universal if when-
ever

9.6 More about sums

287

B1

h1

A1(cid:45)f1

g1

(cid:63)
A(cid:45)

(cid:63)
B

f
are pullbacks, then so is

B2

h2

A2(cid:45)f2

g2

(cid:63)
B

(cid:63)
A(cid:45)

f

B1 + B2

(cid:45)f1 + f2

A1 + A2

(cid:104)h1|h2(cid:105)

(cid:63)
B

f

(cid:104)g1|g2(cid:105)
(cid:63)
A(cid:45)

In addition it is required that if 0 denotes the initial object of the category,
then for any arrow B −→ A, the diagram

0

0(cid:45)

(cid:63)
B

(cid:63)
A(cid:45)

must be a pullback. The meaning of these two conditions together can be
summarized by the statement that pullbacks preserve ﬁnite sums. A ﬁnite
sum is either of no objects, one object, or two or more. The sum of no objects
is the initial object; of one it is the object in question and the condition is
vacuous since the identity functor preserves everything and the condition for
more than two follows immediately from the one for two.

Although ﬁnite (and inﬁnite) sums are universal in the category of sets,
they are not in many familiar categories. In the category of monoids, for
example, the initial monoid 0 is the monoid with one element. Let us consider
Z as a monoid with one generator x; in this guise, its elements are all powers
xn for n positive, negative or zero, and multiplication is deﬁned by xmxn =
xm+n. Let Z(cid:48) be a copy of Z with generator y. The sum Z + Z(cid:48) consists of all
ﬁnite words in powers of x and powers of y, with multiplication illustrated
by

and

x2y−2x4 · x−1y3 = x2y−2x3y3

y3x−2 · y−2x6 = y3x−2y−2x6

288

Limits and colimits

Deﬁne the arrow Z + Z(cid:48) −→ Z by letting the generators x and y both go to
x. The words in powers of x and y that go to the identity element x0 are
all those whose exponents add up to 0, for example any word of the form
xny−n. On the other hand, in each summand the only word going to x0 is
the identity x0 or y0. The pullback of

Z + Z

0

(cid:63)
Z(cid:45)

consists of all the elements of Z + Z(cid:48) that go to x0 and so is not the initial
object 0. Thus this pullback does not preserve ﬁnite sums. (See Exercise 4.)

9.6.7 Deﬁnition A category is called an FLS category (for ﬁnite limits
and sums) if it has ﬁnite limits and ﬁnite sums and the sums are disjoint
and universal.

9.6.8 Coherent categories A category is called coherent if it is both
FLS and regular. A functor between coherent categories is called coherent
if it preserves ﬁnite limits, ﬁnite sums and regular epimorphisms. Coherent
categories correspond to an important type of logic called positive logic.
See [Makkai and Reyes, 1977].

(cid:80)

9.6.9 Inﬁnite universal sums
sum A =
arrow B −→ A, we have that the natural arrow
morphism. To explain this in more detail, for each i, let

In a category with pullbacks, an inﬁnite
Ai with transition arrows ui : Ai −→ A is universal if for any
B ×A Ai −→ B is an iso-

(cid:80)

Bi

vi

(cid:63)
B

Ai(cid:45)

ui

(cid:63)
A(cid:45)

be a pullback. Then the assertion that the sum is universal is equivalent to
the assertion that the cocone with elements vi : Bi −→ B is a sum.

9.7 Uniﬁcation as coequalizer

289

9.6.10 Exercises

1. Prove that Diagram (9.8) is a pushout in any category.

2. Prove that if Diagram (9.9) is a pushout then C is the sum of A and B
with canonical injections i and j.

3. Prove that Set has universal sums.
4.† Let E denote the one-element semigroup. Note that it is a monoid. Show
that in the category of semigroups, E + E is inﬁnite, but in the category
of monoids, E + E = E. (Hint for the ﬁrst part: Let u : N −→ N denote the
function which adds 1 to even integers but leaves odd integers alone, and
v : N −→ N the function which adds 1 to odd integers but leaves even integers
alone. Note that u and v are both idempotent, but that the composites
(u ◦ v)n, n = 1, . . . , n are all diﬀerent.)
5.† Let S be the semigroup with two elements 0 and 1 under the usual
multiplication of numbers. Show that even though both {0} and {1} are
subsemigroups and each is the set-theoretic complement of the other, they
are not complementary subobjects of S and that, in fact, their sum in the
category of semigroups is inﬁnite.
6.† (For those who know something about computability.)

a. Prove that there is a category whose only object is the set of natural
numbers and whose arrows are the computable (recursive) functions with
the usual composition of functions as composition.

b. Show that in this category there are subobjects without complements.
7.† Show that a category with 1 and universal countable sums has a stable
natural numbers object. (See Section 5.5 and especially Theorem 5.5.5.)

9.7 Uniﬁcation as coequalizer

A uniﬁcation of two expressions is a common substitution which results in
the two expressions becoming the same. This may not be possible, but when
it is, there is a least such expression. We shall formulate this as the existence
of a coequalizer (Theorem 9.7.5 below).

9.7.1 As an example, suppose we have a structure with three sorts, A, C
and S, and two operations m : A × A −→ S and t : C × C −→ A. If a, b ∈ A
and u, v, w ∈ C, then we can construct terms

x1 = m(t(u, v), a)
y1 = m(a, a)
x2 = m(b, t(u, w))
y2 = m(b, a)

(9.10)

290

Limits and colimits

all of type S. As it happens, the substitutions

in (9.10) produce

w ← v
a ← t(u, v)

x(cid:48)
1 = m(t(u, v), t(u, v))
y(cid:48)
1 = m(t(u, v), t(u, v))
x(cid:48)
2 = m(b, t(u, v))
y(cid:48)
2 = m(b, t(u, v))

(9.11)

(9.12)

i = y(cid:48)

so that x(cid:48)
i for i = 1, 2. Moreover, any other substitution in (9.10) which
causes those equations to be true can be obtained by a further substitution
in (9.12), so that the substitution in (9.10) is a uniﬁcation of (x1, y1) with
(x2, y2).

9.7.2 Free sketches Let us say that an FP sketch is a free FP sketch
if it has no diagrams and if any node that is the vertex of a cone appears
in that cone only. The nodes look like s1 × s2 × · · · × sn and although the
operations generally have the form

f : s1 × · · · × sn −→ t1 × · · · × tm

we can without loss of generality suppose that the target of any operation
is actually not a product node. The reason is that a function to a product
is, by Deﬁnition 5.3.1, completely determined by the functions obtained by
composing it with the projections, so you can always replace a function to
a product of n objects by n functions, one to each object in the product.

If we have a cone with base nodes s1, . . . , sn and vertex s, which we
generally denote s1 × · · · × sn, then a free algebra with a generator x of
type s and possibly other generators, contains the elements p1(x), . . . , pn(x)
of type s1, . . . , sn, respectively. It is clear that it is isomorphic to a free
algebra generated by elements x1, . . . , xn of types s1, . . . , sn, respectively.
Thus every free algebra is isomorphic to a free algebra in which all the given
elements have types that are not vertices of any cone. Let us temporarily
call this a basic free algebra. Let us also say that a term in a free algebra
that has no projection in it is a proper term.

9.7.3 Proposition In a basic free algebra, every element has a unique ex-
pression as a proper term.

Proof. As noted above, we can suppose that each operation in the sketch has
a base node as its codomain. Then we can apply the construction of 7.6.5
using only FP–1 and FP–3. In this way we build up words in which no

9.7 Uniﬁcation as coequalizer

291

instance of a projection appears. From FP–1, it follows that the elements we
construct are closed under the operations of the sketch and from FP–3 the
elements of the product types are products of those of the base types. This
is a model of the sketch since no equations are required and it is free since
there are no identiﬁcations.

A set of terms in a free algebra can be viewed as a map from a free
algebra. For example, the pair of terms {x1, x2} in 9.7.1 can be seen as an
arrow between free algebras:

x : F ({1, 2}) −→−→ F ({a, b, u, v, w})

Here 1 and 2 both represent variables of type S and x is the unique arrow
that takes 1 to m(t(u, v), a) and 2 to m(b, t(u, w)). Similarly, {y1, y2} can be
viewed as the unique arrow y that takes 1 to m(a, a) and 2 to m(b, a). A
uniﬁcation is then an arrow which coequalizes these two arrows. In particular,
in this example the arrow d in the theorem below is the substitution (9.11).

9.7.4 Proposition Let h : F (X) −→ F (W ) be a map in C . Then either
there is a subset W0 ⊆ W that factors h or h is an epimorphism in C .

Proof. Assume that F (X) and F (W ) are basic free algebras. For each x ∈ X,
h(x) is either an element w ∈ W or has the form f (u1, . . . , un) where f is an
n-ary operation in the sketch and f is not a projection and u1, . . . , un are
elements of F (W ) less complicated than f (u1, . . . , un). If each u1, . . . , un is
represented by a proper term, then f (u1, . . . , un) is also a proper term. We
say that w ∈ W is involved in h(x) either if h(x) = w or, by induction, if it
is involved in one of u1, . . . , un. If some element of W is not involved in any
of the h(x) for x ∈ X, then the ﬁrst alternative holds. So suppose that every
element of W is involved in at least one h(x). Suppose that k (cid:54)= l : F (W )
−→ F (T ) where we may also suppose that F (T ) is a basic free algebra. Then
for some w ∈ W , we must have k(w) (cid:54)= l(w) since two homomorphisms that
agree on generators are equal. If we suppose, as inductive hypothesis, that
at least one k(ui) (cid:54)= l(ui) it follows that

k(f (u1, . . . , un)) = f (k(u1), . . . , k(un))
(cid:54)= f (l(u1), . . . , l(un))
= l(f (u1, . . . , un))

since homomorphisms cannot introduce projections and the representations
are unique. But this shows that k (cid:54)= l implies that k ◦ h (cid:54)= l ◦ h so that h is
an epimorphism in C .

292

Limits and colimits

9.7.5 Theorem Let S be a free FP sketch and C be the full subcategory
of free algebras in the category of models of S in Set. Suppose X, Y and
Z are ﬁnite sets typed by the objects of S . Suppose there is a diagram in
C ,

F (X)

d 0
−−−→−−−→
d 1

F (Y )

d

−−→ F (Z)

(9.13)

with d ◦ d 0 = d ◦ d 1. Then the arrows d 0 and d 1 have a coequalizer in C (so
that this coequalizer is also a free algebra).

Proof. This proof is adapted from that of [Rydeheard and Burstall, 1985].
The proof makes use of the fact that F preserves sums, which follows from
Theorem 13.3.7.

We can suppose that the free algebras involved are basic. The proof will
be by a double induction. The ﬁrst induction is on the complexity of the
arrows d 0 and d 1 and the second on the number of elements of X. By the
depth of the induction, we mean the largest number of steps necessary to
express each d0(x) and each d1(x), for x ∈ X as proper terms using FP–1
and FP–3 as explained above.

We consider ﬁrst the case that X consists of a single element x of some
type. Let d 0(x) = f 0(a1, . . . , an) and d 1(x) = f 1(b1, . . . , bm) where f 0 and
f 1 are operations of the sketch and a1, . . . , an, b1, . . . , bm are proper terms.
Note that it is possible that n = m = 0.

Now we have

d ◦ d 0(x) = df 0(a1, . . . , an) = f 0(da1, . . . , dan)

and similarly,

d ◦ d 1(x) = f 1(db1, . . . , dbm)
It can be seen by induction that da1, . . . , dan and db1, . . . , dbm are still
proper since the value simply percolates upward from the values on the
generators y ∈ Y and projections are never introduced. Setting the terms
equal and using Proposition 9.7.3, we conclude that

m = n,

f 0 = f 1

and

dai = dbi for i = 1, . . . , n

(9.14)

Now d preserves type so the type of ai is the same as that of bi. Let
W be a set {w1, . . . , wn} where wi is a variable of the same type as ai.
(If ai and aj are of the same type for some distinct i and j, wi and wj
are nevertheless distinct variables.) We have arrows e0, e1 : F (W ) −→−→ F (Y )
given by e0(wi) = ai and e1(wi) = bi. This gives us a commutative diagram

F (W )

e0
−−→−−→
e1

F (Y )

d

−−→ F (Z)

(9.15)

The complexities of e0 and e1 are evidently less than those of d 0 and d 1 and
so we can suppose that there is a coequalizer diagram in C

9.7 Uniﬁcation as coequalizer

293

F (W )

e0
−−→−−→
e1

F (Y )

e

−→ F (V )

(9.16)

Let h : F ({x}) −→ F (W ) take x to f 0(w1, . . . , wn) = f 1(w1, . . . , wn) by (9.14).
Then h is epimorphic by Proposition 9.7.4, so by Exercise 1,

F ({x})

e0 ◦ h
−−−−−→−−−−−→
e1 ◦ h

F (Y )

e

−→ F (V )

(9.17)

is a coequalizer diagram. This completes the proof when X has one element.
Now we suppose that X has more than one element and that the conclu-
sion is true for any set with fewer elements. Let x ∈ X be arbitrary. Since
we are supposing that d ◦ d 0 = d ◦ d 1, we can compose both arrows with the
inclusion g : F ({x}) −→ F (X) induced by the inclusion of {x} into X and
use the single element case to get a coequalizer

F ({x})

d 0 ◦ g
−−−−−→−−−−−→
d 1 ◦ g

F (Y )

e

−→ F (V )

(9.18)

Now we let h : X − {x} −→ X be the inclusion and invoke the second in-
duction on the number of elements of X to conclude that there is also a
coequalizer diagram

F (X − {x})

e ◦ d 0 ◦ h
−−−−−−−−→
−−−−−−−−→
e ◦ d 1 ◦ h

F (V )

c

−→ F (U )

(9.19)

It now follows from this, the fact that F preserves sums, and Exercise 3 that
c ◦ e is the coequalizer of the original pair of arrows.

This proof is made into a formal algorithm in [Rydeheard and Burstall,

1986]. See also [Goguen, 1988].

It should be noted that the coequalizer in C constructed in the preceding

proof need not be the coequalizer in the category of all models of S .

294

Limits and colimits

9.7.6 Exercises

1. Show that in any category if

A

f
−−→−−→
g

c
−→ C

B

is a coequalizer diagram and e : D −→ A is an epimorphism, then

D

f ◦ e
−−−−→−−−−→
g ◦ e

c
−→ C

B

is a coequalizer diagram.

2. Show that in any category in which the sums exist, if for i = 1, 2

Ai

fi−−→−−→
gi

ci−−→ Ci

Bi

are both coequalizer diagrams, then so is

A1 + A2

f1 + f2
−−−−−−→
−−−−−−→
g1 + g2

B1 + B2

c1 + c2

−−−−−−→ C1 + C2

3. Prove: If d0, d1 : A1 + A2 −→ B is a parallel pair, with ui : Ai −→ A1 + A2
the coproduct injections for i = 1, 2, if e : B −→ C is a coequalizer of d0 ◦ u1
and d1 ◦ u1 and if c : C −→ D is a coequalizer of e ◦ d0 ◦ u2 and e ◦ d1 ◦ u2,
then c ◦ e : B −→ D is a coequalizer of d0 and d1.

9.8 Properties of factorization systems

Recall the deﬁnition of factorization systems from Section 2.10 of Chapter 2.
In this section, we use a kind of limit to infer the existence of one kind of
factorization system and also an important property of factorization systems.

9.8.1 Intersections
If C is an object of C and C1 ⊆ C and C2 ⊆ C are
two subobjects, then the intersection of C1 and C2 is deﬁned to be a
pullback, if it exists:

C0

(cid:63)
C2

C1(cid:45)

(cid:63)

C(cid:45)

9.8 Properties of factorization systems

295

This is not the only possible deﬁnition. One might be tempted to deﬁne the
intersection as the meet, if it exists, in the poset of subobjects of C. When
the intersection exists, it is the meet in the subobject poset, but it is possible
for that meet to exist without being the pullback, see Exercise 2. But the
meet is not useful if it does not have the universal mapping property of the
pullback.

Similarly, if {Ci | i ∈ I} is any collection of subobjects of C, we deﬁne the
intersection as the limit, if it exists, of the following diagram. Let G denote
the graph with one node i for each i ∈ I together with one more node we
will call ∞. The only arrows are one arrow i −→ ∞ for each i ∈ I. Deﬁne the
diagram D : G −→ C by Di = Ci for i ∈ I, D∞ = C and D(i −→ ∞) is the
inclusion. As before, a limit of such a diagram, if it exists, is the meet in the
poset of subobjects of C, but such a meet could exist without being a limit.
We say that C has wide intersections if for every object C and every

class of subobjects {Ci} of C, there is an intersection.

The reader may have noticed that we did not say every set of subobjects, but
every class, allowing for the possibility that the collection of subobjects of some
object might not be a set (see Section 1.1.3). In the familiar categories that arise
in mathematics and computer science every object has only a set of subobjects and
the distinction we are making here is empty. Readers will lose little if they replace
“class” by “set” in the deﬁnition above. They will have to add to the theorem below
the requirement that each object have a set of subobjects.

9.8.2 Theorem Suppose C is a category with wide intersections in which
every ﬁnite diagram has a limit. Then there is a factorization system E /M
in which E consists of the class of extremal epimorphisms and M consists
of the class of monomorphisms.

e

Proof. Given f : A −→ B, let C ⊆ B denote the intersection of the class of
all subobjects of Bi ⊆ B for which there is a factorization of f as A −→ Bi
−→ B. The universal mapping property of intersection implies that there is
a factorization of f as A
−−→ B. If the arrow e : A −→ C were not
epic, there would be two arrows, say g (cid:54)= h : C −→ D with g ◦ e = h ◦ e. But
then the equalizer of g and h would be a subobject of B strictly smaller than
C that factors e and hence f , a contradiction. The fact that e is extremal
follows since if it factored as e = n ◦ g with n monic and not an isomorphism,
then the image of m ◦ n would be a subobject of B even smaller than B0
that factored f . This shows that every arrow factors as an extremal epic

−→ C

m

296

Limits and colimits

followed by a monic. Now suppose that

A

B(cid:45)e

f

g

(cid:63)
C

(cid:63)
D(cid:45)

m

is a commutative square with e ∈ E and m ∈ M . Let

A(cid:48)

B(cid:45)m(cid:48)

f (cid:48)

g

(cid:63)
C

(cid:63)
D(cid:45)

m

be a pullback. Then m(cid:48) is monic since a pullback of a monic is always monic
(see 9.3.4). There is a unique arrow h : A −→ A(cid:48) such that m(cid:48) ◦ h = e and f (cid:48) ◦
h = f . The fact that e is an extremal epic implies that m(cid:48) is an isomorphism
and then f (cid:48) ◦ m(cid:48)−1 is the required diagonal ﬁll-in since f (cid:48) ◦ m(cid:48)−1 ◦ e = f (cid:48) ◦
m(cid:48)−1 ◦ m(cid:48) ◦ h = f (cid:48) ◦ h = f and m ◦ f (cid:48) ◦ m−1 = g ◦ m(cid:48) ◦ m(cid:48)−1 = g. If k were
another diagonal ﬁll-in, then from m ◦ k = g and m ◦ f (cid:48) ◦ m−1 = g we can
cancel the monic m to conclude that k = f (cid:48) ◦ m−1.

Of course, there is a dual theorem with epics and extremal monics in a

wide cocomplete category.

The proof of the theorem above used the fact that a pullback of a monic
is monic. This property is valid for the arrows in the M part of any factor-
ization system.

9.8.3 Proposition Suppose C is a category and E /M is a factorization
system on C . Then in any commutative square

A

g

(cid:63)
C

B(cid:45)f

h
(cid:63)
D(cid:45)

k

(9.20)

if the square is a pullback, then k ∈ M implies f ∈ M ; if the square is a
pushout, then f ∈ E implies k ∈ E .

9.8 Properties of factorization systems

297

Proof. Assume that diagram (9.20) is a pushout and that f ∈ Σ. We prove
the second assertion using Proposition 2.10.8; the ﬁrst is dual. Suppose we
have a commutative square

C

c

D(cid:45)k

d
(cid:63)

F(cid:45)

(cid:63)
E

m

with m ∈ M . The diagonal ﬁll-in in the square

A

B(cid:45)f

c ◦ g

d ◦ h
(cid:63)

F(cid:45)

(cid:63)
E

m

implies the existence of an arrow l : B −→ E such that l ◦ f = c ◦ g and
m ◦ l = d ◦ h. The latter equation, in conjunction with the universal mapping
properties of pushouts implies the existence of an arrow b : D −→ E such that
b ◦ h = l and b ◦ k = c. The latter equation is one of the diagonal triangles.
We show the second, m ◦ b = d by composing both sides with h and k, using
the uniqueness of arrows from a pushout. We have m ◦ b ◦ h = m ◦ l = d ◦ h
and m ◦ b ◦ k = m ◦ c = d ◦ k.

9.8.4 Exercises

1. Show that when C has cokernel pairs, the converse of Proposition2.10.7
of Chapter 2 is valid; that is, the left cancellability of M implies that every
arrow in E is an epimorphism.

2. a. Show that an intersection, if it exists, of a collection of subobjects of
an object is also its meet in the subobject poset.

b. Show by counter-example (a ﬁnite category should suﬃce) that the

meet of subobjects can exist without being their intersection.

10
More about sketches

This chapter develops the concept of sketch in several ways. The ﬁrst three
sections describe a generalization of FP theories called FL theories which
allow the use of equalizers, pullbacks and other limits in the description of
a structure. These theories have expressive power which includes that of
universal Horn theories.

The last section gives further generalizations of the concept of sketch.
These generalizations are described without much detail since they do not
appear to have many applications (yet!) in computer science.

This chapter is needed only for Chapter 11, except that the sketch for

categories of Section 10.1.5 is required for Section 15.7.

10.1 Finite limit sketches

A cone is called ﬁnite if its shape graph is ﬁnite, meaning that it has only
ﬁnitely many nodes and arrows.

10.1.1 Deﬁnition A ﬁnite limit or FL sketch S = (G , D, L ) is a ﬁnite
graph together with a ﬁnite set D of diagrams and a ﬁnite set L of ﬁnite
cones. A model of S is a model of G that takes all the diagrams in D to
commutative diagrams and all the cones in L to limit cones.

For historical reasons, FL sketches are also known as left exact sketches

or LE sketches.

In 7.2.8 we described the way the choice of products and terminal objects
in a model to represent the vertices of cones in a sketch were irrelevant
but could result in the technicality that, for example, the set representing
the product might not actually be a set of ordered pairs. The same sort of
statement is true of models of FL theories. In particular, in a model the
equalizer of parallel arrows need not be a subset of their common domain.
FL sketches allow the speciﬁcation of structures or data types with sorts
that include equationally speciﬁed subsorts, by using equalizers. More gen-
erally, you can specify an operation whose domain, in a model, will be an
equationally deﬁned subobject of another sort. FL theories can express any-
thing expressible by universal Horn theories, but in general FL theories are

299

300

More about sketches

more powerful (see [Barr, 1989] and [Ad´amek and Rosiˇcky, 1994], pages 209-
210). For example, small categories and functors form the category of models
of an FL theory (which we give in 10.1.5 below) but not of a universal Horn
theory. Categories of models of FL sketches can be described axiomatically
as locally ﬁnitely presentable categories (see [Gabriel and Ulmer, 1971]
and [Ad´amek and Rosiˇcky, 1994]).

In practice it is generally suﬃcient to restrict the types of cones to a few
simple types, products, pullbacks and equalizers. In principle, an FL sketch
can always be replaced by one which has an equivalent category of models
and which has only these three types of cones, but there might be some case
in which this is not the most eﬃcient approach.

10.1.2 Other approaches In the introduction to Chapter 7, we men-
tioned three approaches to formalization: logical theories, signatures and
equations, and sketches. Systems equivalent to FL sketches have been de-
veloped for both the other approaches. Coste [1976], Cartmell [1986] and
McLarty [1986] generalize logical systems and Reichel [1987] generalize sig-
natures. The book by Reichel has many examples of applications to computer
science.

10.1.3 Notation for FL sketches We extend the notational conventions
in Section 7.3 to cover products, pullbacks and equalizers.

First, the notation of N–2 in 7.3.1 using product projections is extended
to cover the arrows from the limit to any of the nodes in the diagram: that
is they are all denoted by an appropriate p; moreover, the notation of N–4
in 7.3.1 is extended to arrows into the limit in terms of the composite with
the projections. See Example 10.1.5 below of the sketch of categories to see
how this is used. Of course, it is sometimes necessary to be more explicit
than this.

We add the following to the notational conventions of Section 7.3.

N–8 If we have a node labeled a ×c b this implies the existence of a cone

a ×c b
(cid:64)
(cid:161)

(cid:161)

(cid:161)

(cid:161)(cid:170)

a

c(cid:45)

(cid:190)

(cid:64)

(cid:64)

(cid:64)(cid:82)

b

Of course, this notation is not self-contained since it is necessary to
specify the arrows a −→ c ←− b. In many cases, these arrows are clear,
but it may be necessary to specify them explicitly.

10.1 Finite limit sketches

301

N–9 If we have an arrow labeled s : a (cid:41)−→ b (recall from 2.8.2 that in a
category this notation means an arrow that is a monomorphism), then
we are implicitly including a cone

a

s

(cid:64)

(cid:161)

(cid:161)

(cid:63)

(cid:190)

b(cid:45)

id
(cid:161)
(cid:161)(cid:170)

a

s

(cid:64)

id
(cid:64)
(cid:64)(cid:82)

s

a

This notation makes sense because of Theorem 9.3.3.

We could go on and turn our notational conventions into a formal language,
but have chosen not to do so because we do not know what it would add to
the theory. For us, they remain a set of notational conventions; the real object
of study is the whole sketch or else the theory it generates.

10.1.4 The sketch for simple graphs Here is a simple example that
shows how the added power of FL sketches can be used to deﬁne a familiar
type of structure. A simple graph is a graph with the property that for
any pair (a, b) of nodes there is no more than one arrow with source a and
target b.

The sketch for graphs has the graph
source
−−−−−→
−−−−−→
target

a

n

and no cones or diagrams. We can modify it to get a sketch for simple graphs
by adding an object n × n and the necessary discrete cone to make it a formal
product, an arrow u : a (cid:41)−→ n × n (hence adding a formal pullback as in N–9
making it formally monic) and also the diagram (not cone)

(cid:161)

a

u

(cid:64)

(cid:64)

(cid:63)
n × n

target
(cid:64)

(cid:64)(cid:82)
n(cid:45)

p2

(cid:161)

source
(cid:161)

(cid:161)(cid:170)
(cid:190)

n

p1

The eﬀect of this is to make the monic arrow u become (cid:104)source, target(cid:105) in a
model, so that no two arrows can have the same source-target pair.

10.1.5 The sketch for categories We give here an FL sketch whose
models in the category of sets are small categories and arrows between the
models are functors. Models in an arbitrary category C with ﬁnite limits are
called category objects in C . These are used in Section 15.7.

The sketch has nodes c0, c1, c2 and c3 which stand for the objects, the
arrows, the composable pairs and the composable triples of arrows respec-
tively. The arrows of the sketch are:

302

More about sketches

u : c0 −→ c1
s, t : c1 −→ c0
p1, p2, c : c2 −→ c1
p1, p2, p3 : c3 −→ c1
(cid:104)p1, p2(cid:105), (cid:104)p2, p3(cid:105), (cid:104)p1, c(cid:105), (cid:104)c, p3(cid:105) : c3 −→ c2
(cid:104)u ◦ t, id(cid:105), (cid:104)id, u ◦ s(cid:105) : c1 −→ c2

The intention is that in a Set-model, the arrows of the sketch will be

interpreted as follows:

u is the unit function which assigns to each object its identity,

s and t are the source and target functions from the set of arrows to
the set of objects, and
c is the function which takes a composable pair of arrows to its com-
posite.

The remaining arrows of the sketch are projections from a limit or are

interpreted as arrows to a limit with speciﬁed projections.

The diagrams are

c3

(cid:64)
(cid:161)
(cid:104)p2, p3(cid:105)
(cid:63)
c2

(cid:161)

p2
(cid:161)

(cid:161)(cid:170)
(cid:190)

p1

c1

c2 (cid:190)(cid:104)p1, p2(cid:105)

c3

c

(cid:63)
c1

(cid:190)

p1

(cid:64)
(cid:104)c, p3(cid:105)
(cid:63)
c2

c0 (cid:190) t

c1

(cid:64)

p3
(cid:64)
(cid:64)(cid:82)
c1(cid:45)

p2

(cid:64)

p3
(cid:64)
(cid:64)(cid:82)
c1(cid:45)

p2

u

(cid:64)
(cid:104)u ◦ t, id(cid:105)

(cid:64)

(cid:63)
c1

(cid:190)

p1

(cid:63)
c2

id
(cid:64)
(cid:64)(cid:82)
c1(cid:45)

p2

c1

c1

c1

c3

(cid:64)
(cid:161)
(cid:104)p1, p20(cid:105)
(cid:63)
c2(cid:45)

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

p1

(cid:64)

p2
(cid:64)
(cid:64)(cid:82)
c1(cid:45)

p2

c2(cid:45)(cid:104)p2, p3(cid:105)

c3

(cid:161)
(cid:104)p1, c(cid:105)
(cid:63)
c2

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)
(cid:190)

p1

c

(cid:63)
c1(cid:45)

p2

c1

c0(cid:45)s

(cid:161)
(cid:104)id, u ◦ s(cid:105)

(cid:161)

u

(cid:63)
c2

(cid:63)
c1(cid:45)

p2

id
(cid:161)
(cid:161)(cid:170)
(cid:190)

p1

(cid:104)id, u ◦ s(cid:105)

c2(cid:45)

c1

(cid:64)

(cid:64)
id

(cid:64)

(cid:64)

(cid:64)(cid:82)

(cid:190)(cid:104)u ◦ t, id(cid:105)
(cid:161)

(cid:161)
id

(cid:161)

c

(cid:161)

(cid:161)(cid:170)

(cid:63)
c1

10.1 Finite limit sketches

303

c1

c3

(cid:104)p1, c(cid:105)

c2(cid:45)

(cid:104)c, p3(cid:105)

c

(cid:63)
c2

(cid:63)
c1(cid:45)

c

Finally, there are two cones that say that c2 and c3 are interpreted as the

objects of composable pairs and triples or arrows, respectively.

c2

(cid:161)

(cid:64)

(cid:64)

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

c1

(cid:63)
c0(cid:45)

(cid:190)

t

s

(cid:161)

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

c3

p2

(cid:64)

(cid:63)
c1

(cid:64)

p3
(cid:64)

(cid:64)(cid:82)

(cid:161)
(cid:161)
t

(cid:64)
(cid:64)
s

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

(cid:63)
c0

p2
(cid:64)

(cid:64)(cid:82)

c1

c1

s

c1

t
(cid:63)
c0

This sketch is the sketch of categories and is one of the simpler FL sketches
around.

The category of models (in Set) of an FP sketch must be regular (see
[Barr and Wells, 1985], Theorem 1 of Section 8.4) and it can be proved
that the category of categories and functors is not regular (see Exercise 6 of
Section 9.6). It follows that categories and functors cannot be the models of
an FP sketch.

Lawvere [1966] described another structure whose models are categories. Let
1, 2, 3 and 4 denote the total orders with one, two, three and four elements,
considered as categories in the usual way a poset is. Let L denote the opposite
category. In that opposite category, it turns out that 3 = 2 ×1 2 and 4 =
2×12×12. Then Cat is the category of limit-preserving functors of L into Set
with natural transformations as arrows. It follows that the sketch whose objects
and arrows are those of L , whose diagrams are the commutative diagrams of
L and cones are the limit cones of L is another sketch, closely related in fact
to the one above, whose category of models is Cat.

We show how binary trees can be described as models of an FL sketch

in the next section.

304

More about sketches

10.1.6 Exercises

1. A groupoid is a category in which every arrow is an isomorphism. Ex-
plain how to modify the sketch for categories to get a sketch for groupoids.

2. Show that in the category of sets, the deﬁnition of homomorphism be-
tween two models of the sketch for categories gives the usual deﬁnition of
functor.

10.2 Initial term models of FL sketches

Like FP sketches, FL sketches always have initial models. The construc-
tion 7.6.5 produced an initial term algebra for each ﬁnite FP sketch. A mod-
iﬁcation of the last three rules in 7.6.5 is suﬃcient to construct an initial
term algebra for each ﬁnite FL sketch. This will be described below.

A diﬀerent construction is in [Barr, 1986b], where it is proved that in
fact FL sketches have free algebras on any typed set X (see Section 13.2).
Volger [1987] gives a logic-based proof for the special case of Horn theories
(see [Volger, 1988] for applications).

The modiﬁcation of 7.6.5 is required by the fact that the base diagram
D of a cone in L need not be discrete in the case of general limits; that
is, the shape graph I of the diagram D in Section 9.2 may have nontrivial
arrows u : i −→ j. A limit of such a cone in the category of sets is not just
any tuple of elements of the sets corresponding to the nodes of I , but only
tuples which are compatible with the arrows of I .

10.2.1 Precisely, suppose E : I −→ Set is a ﬁnite diagram (we use the
letter E instead of D to avoid confusion below). A compatible family of
elements of E is a sequence (x1, . . . , xn) indexed by the nodes of I for which

C–1 xi ∈ E(i) for each node i.
C–2 If u : i −→ j in I , then E(u)(xi) = xj.

An initial term algebra of an FL sketch S = (G , D, L ) is then the least

model satisfying the following requirements.

FL–1 If f : a −→ b is an arrow of G and [x] is an element of I(a), then

[f x] ∈ I(b) and I(f )[x] = [f x].

FL–2 If (f1, . . . , fm) and (g1, . . . , gk) are paths in a diagram in D, both going
from a node labeled a to a node labeled b, and [x] ∈ I(a), then

(If1 ◦ If2 ◦ . . . ◦ Ifm)[x] = (Ig1 ◦ Ig2 ◦ . . . ◦ Igk)[x]

in I(b).

10.2 Initial term models

305

FL–3 If D : I −→ G is a diagram, ([x1], . . . , [xn]) is a compatible family
of elements of I ◦ D and p : q −→ D is a cone over D in L , then
[C(x1, . . . , xn)] is an element of I(q).

FL–4 If p : q −→ D and ([x1], . . . , [xn]) are as in FL–3, and x(cid:48)

1, . . . , x(cid:48)
a compatible family of elements of I ◦ D for which [xi] = [x(cid:48)
i = 1, . . . , n, then

n is
i] for

[C(x1, . . . , xn)] = [C(x(cid:48)

1, . . . , x(cid:48)

n)]

FL–5 If p : q −→ D and ([x1], . . . , [xn]) are as in FL–3, then for i = 1, . . . , n

[piC(x1, . . . , xn)] = [xi]

FL–6 If p : q −→ D is a cone over D in L and x ∈ I(q), then

[x] = [C(p1x, . . . , pnx)]

Compatibility implies that for any arrow u : i −→ j of I ,

I(D(u))([xi]) = [xj]

As in 7.6.5, it follows that

I(pi)([C(x1, . . . , xn)]) = [xi]

for each i.

10.2.2 Binary trees We describe an FL sketch whose initial term algebra
is the set of binary trees of integers. We gave an FD sketch for binary trees
in 8.3.11; the sketch given here illustrates a diﬀerent approach to the problem
that operations such as taking the datum at the root or producing the left
or right subtrees are not deﬁned on the empty tree.

We have the following basic nodes in the sketch: 1, t, t+, b, n. These
should be thought of as representing the types of binary trees, nonempty
binary trees, the Boolean algebra 2 and the natural numbers, respectively.
We have the following operations:

empty : 1 −→ t
val : t+ −→ n
zero : 1 −→ n
and : b × b −→ b

empty? : t −→ b
left : t+ −→ t
succ : n −→ n
not : b −→ b

incl : t+ −→ t
right : t+ −→ t
true : 1 −→ b

The intended meaning of these operations is as follows: the constant
empty(cid:104)(cid:105) is the empty tree; empty? is the test for whether a tree is the empty
tree; incl is the inclusion of the set of nonempty trees in the set of trees;

306

More about sketches

val(T ) is the datum stored at the root of the nonempty tree T ; left(T ) and
right(T ) are the right and left branches (possibly empty) of the nonempty
tree T , respectively. The remaining operations are the standard operations
appropriate to the natural numbers and the Boolean algebra 2.

We require that

(cid:161)

(cid:161)

left
(cid:161)
(cid:161)(cid:170)

t

t+

(cid:64)

val
(cid:63)
n

t+

and

(cid:64)

right
(cid:64)

(cid:64)(cid:82)

t

(cid:161)

(cid:161)

(cid:64)

(cid:64)

incl
(cid:64)
(cid:64)(cid:82)

t

(cid:161)

(cid:161)(cid:170)

1

(10.1)

(cid:64)
not ◦ true

(cid:64)

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

b

(cid:161)
empty?

(cid:161)

be cones and that

1

t(cid:45)empty
(cid:64)
true

(cid:64)

empty?

(cid:64)

(cid:64)(cid:82)

(cid:63)
b

be a diagram.

In the cone (10.1), there should be an arrow from the vertex to the node b.
It will appear in a model as either of the two (necessarily equal) composites.
Since its value is forced, it is customary to omit it from the cone; however,
there actually does have to be such an arrow there to complete the cone (and
the sketch). In omitting it, we have conformed to the standard convention
of showing explicitly only what it is necessary to show.

As in 8.3.11, the existence of the ﬁrst cone says that every nonempty tree

can be represented uniquely as a triplet

(left(T ), val(T ), right(T ))

The fact that (10.1) is a cone requires that in a model M , M (t+) be ex-
actly the subset of M (t) of those elements which evaluate to false under
M (empty?).

10.3 The theory of an FL sketch

307

10.2.3 Exercise

1. In the sketch for binary trees, show that for any model M , M (incl) is an
injective function. (Hint: use Diagram (10.1).)

10.3 The theory of an FL sketch

Just as in the case of linear and FP sketches, every FL sketch generates a
category with ﬁnite limits in which it has a universal model.

10.3.1 Theorem Given any FL sketch S , there is a category ThFL(S )
with ﬁnite limits and a model M0 : S −→ ThFL(S ) such that for any
model M : S −→ E into a category with ﬁnite limits, there is a functor
F : ThFL(S ) −→ E that preserves ﬁnite limits for which

(i) F ◦ M0 = M , and
(ii) if F (cid:48) : ThFL(S ) −→ E is another functor that preserves ﬁnite limits
for which F (cid:48) ◦ M0 = M , then F and F (cid:48) are naturally isomorphic.

ThFL(S ) is deﬁned up to equivalence by the following properties:

FLT–1 T has all ﬁnite limits.
FLT–2 M0 takes every diagram of S to a commutative diagram in T .
FLT–3 M0 takes every cone of S to a limit cone of T .
FLT–4 No proper subcategory of T includes the image of M0 and satisﬁes

FLT-1, FLT-2 and FLT-3.

The comments concerning Theorem 7.5.1 apply here too. See [Barr and
Wells, 1985], Section 4.4, Theorem 2 (p. 156). The constructions in [Ehres-
mann, 1968] and [Bastiani and Ehresmann, 1972] are more general since they
allow cones over inﬁnite diagrams.

10.3.2 Example The sketch for semigroups (see Section 7.2) is an FP
sketch and therefore an FL sketch whose cones all go to discrete diagrams.
The FL theory of this sketch contains a node v that is the limit of this
diagram:

s

(cid:64)
id

s × s(cid:45)∆
(cid:161)
c

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

s

(10.2)

Since M0 is injective, we write s for M0(s), s × s for M0(s × s), and so on.
A model M of the sketch induces a limit preserving functor F which
must take v to a set. Since v is the equalizer of ids and c ◦ ∆, F (v) must be

308

More about sketches

the set of elements e of M (s) that satisfy the requirement ee = e, that is,
the set of idempotents in the semigroup M (s). (This set is not in general a
subsemigroup.)

10.3.3 Example The FL theory of the sketch for categories (see 10.1.5)
contains a node v that is the limit of the diagram

c1

(cid:64)

c0

(cid:161)

s
(cid:161)
(cid:161)(cid:170)

(cid:64)(cid:73)
s
(cid:64)

(cid:161)

(cid:64)

c1

t
(cid:64)
(cid:64)(cid:82)

(cid:161)(cid:181)
(cid:161)
t

c0

(10.3)

If C is a small category, hence a model of the sketch, the induced limit-
preserving functor F takes v to the set of all parallel pairs of arrows in C .

10.3.4 Exercises

1. The following diagram in the sketch for categories has a limit v in the FL
theory of that sketch. What is its value in a model?
c1

c1

c1
s

(cid:64)

t
(cid:64)

(cid:161)
s

(cid:161)

(cid:64)
t

(cid:64)

(cid:161)

s
(cid:161)

t

(cid:161)
(cid:64)

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

(cid:63)
c0

(cid:64)
(cid:161)

(cid:161)

(cid:161)(cid:170)

c0

(cid:64)

(cid:64)(cid:82)

(cid:63)
c0

2. Same question as Exercise 1 for the following diagram:

(cid:161)

c2

(cid:161)

(cid:64)

c

(cid:63)
c1

(cid:161)

p1
(cid:161)

(cid:161)(cid:170)

(cid:64)

(cid:64)

p2
(cid:64)

(cid:64)(cid:82)

(cid:64)

t
(cid:64)

(cid:161)

(cid:64)
(cid:161)

(cid:161)
s

(cid:64)
t

(cid:161)

s
(cid:161)

(cid:64)

(cid:64)
(cid:161)

c1

t

c1
s

(cid:161)

(cid:161)(cid:170)

(cid:63)
c0

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

c0

(cid:64)

(cid:64)(cid:82)

(cid:63)
c0

3. Show that any model M of a sketch S is isomorphic to a model M (cid:48) for
which M (cid:48)(c) and M (cid:48)(d) have no elements in common if c (cid:54)= d.

10.4 General deﬁnition of sketch

10.4 General deﬁnition of sketch

309

Although we will not be using the most general notion of sketch, we give the
deﬁnition here.

10.4.1 Deﬁnition A sketch S = (G , D, L , K ) consists of a graph G , a
set D of diagrams in G , a set L of cones in G and a set K of cocones in G .

10.4.2 Deﬁnition A model M of a sketch S = (G , D, L , K ) in a cate-
gory A is a homomorphism from G to the underlying graph of A that takes
every diagram in D to a commutative diagram, every cone in L to a limit
cone and every cocone in K to a colimit cocone.

10.4.3 Deﬁnition Let M , N be models of a sketch S in a category A . A
homomorphism of models α : M −→ N is a natural transformation from
M to N .

Sketches in general do not have initial algebras, or even families of initial
algebras. What they do have is ‘locally free diagrams’ as described by Guitart
and Lair [1981, 1982].

10.4.4 Regular sketches Chapter 8 of [Barr and Wells, 1985] describes
special classes of sketches with cones and cocones that have in common
the fact that their theories are embedded in a topos, and so inherit the
nice properties of a topos. (Toposes are discussed in Chapter 15.) These are
the regular sketches, coherent sketches and geometric sketches. We describe
regular sketches here to illustrate the general pattern. (Note: The French
school uses the phrase “regular sketch” for a sketch in which no node is the
vertex of more than one cone.)

10.4.5 An arrow f : A −→ B is a regular epimorphism if and only if there
is a cocone diagram

C

g
−−→−−→
h

f

−−→ B

A

It follows that the predicate of being a regular epimorphism can be stated
within the semantics of a ﬁnite limits sketch. Note that an arrow can be
required to become an epimorphism (not necessarily regular) in a model by
using the dual of Theorem 9.3.3.

Let us say that a regular cocone is one of the form

c −→−→ a −→ b

310

More about sketches

10.4.6 Deﬁnition A regular sketch S = (G , D, L , K ) consists of a
graph, a set of diagrams, a set of ﬁnite cones and a set of regular cocones.

There is one undesirable feature to the deﬁnition above. The introduction
of a regular sketch requires the introduction of a sort c and two arrows c −→−→ a.
A model will have to provide a value for c as well as the two arrows. This is
generally irrelevant information that one would not normally want to have to
provide. Worse, the deﬁnition of natural transformation is such that arrows
between models will have to preserve this additional information and that
is deﬁnitely undesirable. The way in which this is usually dealt with is by
adding, with each cocone

the cone

c

d 0
−−−→−−−→
d 1

d
−−→ b

a

a(cid:45)d 0

c

d 1

(cid:63)
a

d
(cid:63)

b(cid:45)

d
It follows from Exercise 5 of Section 9.4 that if d has a kernel pair, then d is a
regular epimorphism if and only if it is the coequalizer of that kernel pair. The
addition of this cone thus adds no new data, at least in the case of models in
a category with ﬁnite limits and coequalizers. The preservation of the kernel
pair and the two arrows by homomorphisms of models is automatic, given
the universal mapping properties of limits.

The point of these considerations is that a regular sketch can be de-
scribed as one in which one can specify any kind of ﬁnite limits and that any
particular arrow is a coequalizer of some pair, without having to specify (or
preserve in an arrow between models) what pair of arrows it coequalizes.

One of the things we want a sketch to do is minimize the number of items –
or amount of information – that has to be speciﬁed and maximize the amount
that is implicit in the sketch. Thus we want to be able to say that an arrow
is a regular epimorphism (that is, coequalizer of some pair of arrows) without
specifying what pair it coequalizes. In the preceding discussion, we described
a way to do this: to observe that a regular epi is a coequalizer of its own
kernel pair and that the kernel pair can be calculated. There is a price to
pay in solving the problem in this way, since this works only when you form
models in a category that has that kernel pair. An alternative approach would
be to simply add regular epi to the list of primitives that a sketch can make
use of, so that one could require than an arrow be a regular epi, without
having to specify the arrows it coequalizes, in a category that may or may
not have pullbacks. This is an example of expanding the concept of sketch to
allow speciﬁcation of constructions other than commutative diagrams, limits

10.4 General deﬁnition of sketch

311

and colimits. (References to generalized sketches are given at the end of this
chapter.)

As an example, we construct a sketch for weakly reﬂexive graphs – graphs
with the property that there is at least one loop on each node. Morphisms
will be ordinary morphisms of graphs. (So the models should be the full
subcategory of Grf of weakly reﬂexive graphs.) The problem that arose
in 4.6.9 that homomorphisms had to take certain speciﬁc loops to other
speciﬁc loops does not arise in this construction.

We take the sketch for graphs with nodes n and a and arrows source : a

−→ n and target : a −→ n. We add a new type r with a cone

r −→ a

source
−−−−−→
−−−−−→
target

n

and a cocone to express that the composite r −→ a −→ n (the latter arrow
being either source or target) is regular epic. In a model, r becomes the set
of loops. The fact that the arrow r −→ a −→ n maps surjectively to the nodes
implies that there is at least one loop at each node. A homomorphism from
M to M (cid:48) must take M (r) to M (cid:48)(r) as a set, but there is no particular loop
in M (r) that is distinguished by the construction.

10.4.7 Theories of sketches with colimits. The reader may have no-
ticed that in Chapter 7, we discussed FP sketches, their initial algebras and
their theories, and in Chapter 8 we discussed FD sketches and their initial
algebras. We did not discuss theories for FD sketches. In fact, theories exist
for FD sketches, and indeed for all sketches. This is because sketches can
themselves be modeled by an FL theory, and the theory of a sketch can then
be realized as an initial algebra (see Section 10.2). See [Wells, 1990], [Bagchi
and Wells, 1997a]. The theories of many types of sketches can be constructed
as subcategories of toposes; this is done in [Barr and Wells, 1985], Chapters 4
and 8. Other constructions of theories for special kinds of sketches are given
in [Ehresmann, 1968], [Bastiani and Ehresmann, 1972], [Peake and Peters,
1972], [Kelly, 1982b]. [Bagchi and Wells, 1997a].

Here, we state the universal properties for theories of FD sketches for
models in categories with ﬁnite products and ﬁnite disjoint universal sums.
The resulting theory has these properties, too, and is embedded in a topos.
The proof by initial algebras just mentioned does not give such an embed-
ding.

10.4.8 Theorem Let S be an FD sketch. Then there is a category de-
noted ThFD(S ) with ﬁnite disjoint universal sums and a model M0 : S −→
ThFD(S ) such that for any model M : S −→ E into a category with ﬁnite

312

More about sketches

products and ﬁnite disjoint universal sums, there is a functor F : ThFD(S )
−→ E that preserves ﬁnite products and ﬁnite sums for which

(i) F ◦ M0 = M , and
(ii) If F (cid:48) : ThFD(S ) −→ E is another functor that preserves ﬁnite products
and ﬁnite sums for which F (cid:48) ◦ M0 = M , then F and F (cid:48) are naturally
isomorphic.

A proof may be found in [Barr and Wells, 1985], Proposition 1 of Section
8.2 (FD sketches are called FS sketches there) and in [Bagchi and Wells,
1997a].

The situation is similar for regular sketches.

10.4.9 Theorem Let S be a regular sketch. Then there is a regular cate-
gory denoted ThReg(S ) and a model M0 : S −→ ThReg(S ) such that, for
any model M : S −→ E into a regular category, there is a regular functor
F : ThReg(S ) −→ E such that

(i) F ◦ M0 = M , and
(ii) if F (cid:48) : ThReg(S ) −→ E is another regular functor for which F (cid:48) ◦ M0 =

M , then F and F (cid:48) are naturally isomorphic.

10.4.10 Categories of set-valued models of general sketches can be axiom-
atized as accessible categories (see [Makkai and Par´e, 1990], [Ad´amek and
Rosiˇcky, 1994].) A precise statement of the relationship between categories
of models of ﬁrst order theories and categories of models of sketches is given
in [Ad´amek and Rosiˇcky, 1994] (Theorems 5.35 and 5.44).

Generalizations of the concept of sketch are given by Lair [1987], Wells
[1990], Power and Wells [1992], and Makkai [1997]. See also [Barr and Wells,
1992] and [Bagchi and Wells, 1997a].

11
The category of sketches

The ﬁrst section of this chapter deﬁnes the concept of homomorphism of
sketches, yielding a category of sketches. In Section 11.2 we describe a for-
malism for deﬁning parametrized data types using sketch homomorphisms.
In Section 11.3 we develop the theory of sketches further, showing that
a homomorphism of sketches induces a contravariant functor between the
model categories and making contact with Goguen and Burstall’s concept of
institution.

Section 11.3 requires only Section 11.1 to read. Nothing in this chapter

is needed later in the book.

Much more is known about the category of sketches than is mentioned
here. It is cartesian closed, for example. A basic study in English of the
category of sketches which is oriented toward computer science is given by
Gray [1989].

11.1 Homomorphisms of sketches

11.1.1 Let S = (G , D, L , K ) and S (cid:48) = (G (cid:48), D (cid:48), L (cid:48), K (cid:48)) be sketches. A
graph homomorphism F : G −→ G (cid:48) takes a diagram D : I −→ G to a diagram
F ◦ D : I −→ G (cid:48) which is called the image of D in G (cid:48). It takes a cone p : v
−→ D to a cone F (p) : F (v) −→ F ◦ D where, for each node a of the shape
graph of D, F (p)a : F (v) −→ F (D(a)) is deﬁned to be F (pa). It is deﬁned on
cocones similarly.

An arrow or homomorphism of sketches F : S −→ S (cid:48) is a graph
homomorphism from the graph G to the graph G (cid:48) for which, if D is a diagram
in D then F ◦ D lies in D (cid:48); if p : v −→ D is a cone in L then F (p) is a cone
in L (cid:48); and if c : D −→ v is a cocone in K then F (c) is a cocone in K (cid:48).

Note that if in the sketch S the sets of diagrams, cones and cocones are
all empty, then an arrow from S to S (cid:48) is precisely a graph homomorphism
from G to G (cid:48).

11.1.2 Example Let E denote the impoverished sketch which has one
node we will call e and no arrows, diagrams, cones or cocones. Any as-
signment of e to a node of any sketch is a morphism of sketches.

313

314

The category of sketches

11.1.3 Example The sketch for graphs has the graph

a

source
−−−−−→
−−−−−→
target

n

and no cones or diagrams. There is a graph homomorphism from the graph of
the sketch of 4.2.17 to the graph just given that takes 0 to a, 1 to n, and u to
source. This is a sketch homomorphism since there are no diagrams, cones or
cocones in either sketch. (Of course, there is another sketch homomorphism
taking u to target.)

11.1.4 Example In 10.1.4, we modifed the sketch for graphs by adding a
cone making it the sketch for simple graphs. The inclusion of the sketch for
graphs into the sketch for simple graphs is a homomorphism of sketches.

11.1.5 Example A ﬁeld has an associative binary operation of addition
on it, so one would suspect that there is a homomorphism from the sketch
for semigroups in 7.2.1 to the sketch for ﬁelds in 8.2. That is the case. The
homomorphism takes s to f , s × s to f × f and s × s × s to f × f × f , and the
arrow c to the arrow +. The homomorphism must take projection arrows
of cones to corresponding projection arrows, and of course the associativity
diagram (7.8) then is mapped to the diagram implied by FE–1 of 8.2.

11.1.6 The sketch underlying a category Let C be a category. There
is an underlying sketch of C , call it Sk(C ), whose graph consists of the
objects of C as nodes and the arrows of C as arrows. This underlying sketch
is not in general ﬁnite or even small. The commutative diagrams of this
sketch are all diagrams that are commutative in C . Similarly we take for
cones all those that are limit cones in C and for cocones all those that are
colimit cocones. An arrow from S to Sk(C ) is then exactly what we have
called a model of S in C in 10.4.2.

We note that although the composition in C has been forgotten, it can
be completely recovered from the knowledge of which diagrams commute.
For example, the information f ◦ g = h is equivalent to the information that

·

·(cid:45)g

(cid:64)
(cid:64)
h

(cid:64)

(cid:64)(cid:82)

f

(cid:63)
·

commutes so that we could recover the category C entirely from the under-
lying sketch (in fact, just from the graph and the commutative triangles).

11.2 Parametrized data types

315

11.1.7 The category of sketches With the deﬁnition of homomorphism
of sketches given above, sketches themselves form a category which we will
call Sketch. By restricting the shape graphs for the diagrams, cones and
cocones one obtains many full subcategories of Sketch, for example the
category of FP sketches, the category of FD sketches, and so on.

One consequence of this is that all constructions that we can carry out in
any category make sense in the category of sketches. The particular construc-
tion that interests us here is the formation of colimits, particularly pushouts.

11.1.8 Exercise

1. Let E be the sketch with one node and no arrows, diagrams, cones or
cocones. Show that the category of models of E in a category C is isomorphic
to C . In particular, the category of models of E in Set is isomorphic to Set.

11.2 Parametrized data types

as pushouts

One thing a theory of data types should do is give a way of saying how the
data types of stacks of integers, say, is like the type of stacks of reals or for
that matter of stacks of arrays of trees of characters. In other words, we need
a way of talking about an abstract stack in a way that leaves it open to ﬁll
in the blank corresponding to the thing that it is stacks of. The data type is
the parameter.

The way we do this is to describe a sketch for stacks of d where d stands
for an abstract data type and then use a pushout construction to identify d
with a concrete data type in any particular application. The point is that
pushouts are the general way we use to identify things. We give several
illustrations.

11.2.1 Abstract stacks Consider the sketch whose graph consists of nodes
s, t, d, d × s and 1. The idea is that s stands for the set of stack conﬁgu-
rations, t the set of nonempty stack conﬁgurations, and d the data. There
are operations push : d × s −→ t, pop : t −→ d × s, empty : 1 −→ s and incl : t
−→ s. In order to state the equations we also have two arrows idd×s and idt
which will be forced to be identity arrows.

There are four equations (diagrams). Two of them, idd×s = ()d×s and
idt = ()t, force those arrows to be identities, and the following two, which
express the essence of being a stack:

pop ◦ push = idd×s

The category of sketches

316

and

push ◦ pop = idt

There are the cones to express 1 as terminal and d × s as a product, and

one cocone

1

(cid:64)
empty

(cid:64)

(cid:64)

(cid:64)(cid:82)

s

t

(cid:161)
incl

(cid:161)

(cid:161)

(cid:161)(cid:170)

So far, this sketch is not very interesting, since the type of d is still undeter-
mined. In fact its initial model I has I(d) = I(t) = ∅ and I(s) = {empty}.
Note that {empty} is not empty. It contains one element which we interpret
as representing the empty stack. Since the type d of data is empty, the empty
stack is the only kind of stack there is in the model I.

If there were constants in the data type d, then I(s) would be the set of
all possible conﬁgurations of a stack of data of type I(d), and I(t) would be
the set of all possible conﬁgurations other than the empty stack.

11.2.2 Stacks of natural numbers In 4.7.7, we described the sketch
with two nodes, 1 and n, two operations zero : 1 −→ n and succ : n −→ n.
There are no equations (diagrams), just the cone describing 1 as terminal
and no cocones. This sketch, which we called Nat, has models that can
be reasonably viewed as describing natural numbers. We described a more
elaborate sketch in 8.1.4 which could also be used in what follows.

Let us consider the following diagram in the category of sketches, where
E is the trivial sketch deﬁned in Example 11.1.2 and the arrows F and G
are deﬁned by letting F e = n and Ge = d.

E

Nat(cid:45)F

G

(cid:63)
Stack

(11.1)

A pushout of this diagram is a sketch Stack(Nat) made by forming the
union of Nat and Stack and then identifying the node n of Nat with the
node d of Stack.

From the deﬁnition of pushout, it follows that a model of this sketch is
a model of the sketch for natural numbers that is simultaneously a model
of the sketch for stacks whose value at the node d of Stack is the same as
its value at the node n of Nat. Models of this sketch can be identiﬁed as

11.2 Parametrized data types

317

stacks of natural numbers. The eﬀect of this construction is to ﬁll in the data
parameter in the sketch for stacks with an actual data type. Of course, this
data type of natural numbers could be replaced by any data type desired
(including stacks of natural numbers!) by replacing F : E −→ Nat by an
appropriate sketch homomorphism.

Although we think of this sketch as being that of stacks of natural num-
bers, the pushout construction is completely symmetric and any asymmetry
is imposed by our way of looking at it. It is caused by our (quite reasonable)
perception that the node d of Stack is an input parameter and the node s
represents the actual data type.

11.2.3 Binary trees, revisited again Here is a second example. In 8.3.11,
we described a sketch called BinTree and then another sketch of the same
name in 10.2.2. Here we describe yet another sketch we call BinTree. This
third and ﬁnal approach is fully parametrized and represents exactly what
we mean by binary trees, no more and no less. We use nodes 1, t+, t and
d. Now the only operations we put in are empty,
left and right.
We also need the cones and cocones necessary to say that t+ = 1 + t with
inclusions empty and incl and that t+ = t × d × t with projections left, val
and right.

incl, val,

Then if F : E −→ Nat is as above and H : E −→ BinTree is deﬁned by

H(e) = d, then the pushout of

Nat(cid:45)F

E

H

(cid:63)

BinTree

(cid:45)

(cid:63)
BinTree(Nat)

is a sketch whose models can be interpreted as binary trees of natural num-
bers.

11.2.4 Further combinators This operation can be iterated. For exam-
ple, we can form the pushout

E

(cid:45)K

BinTree(Nat)

G

(cid:63)
Stack

(cid:45)

(cid:63)
Stack(BinTree(Nat))

318

The category of sketches

with Ke = t or even

(cid:45)L

Stack(Nat)

E

H

(cid:63)

BinTree

(cid:45)

(cid:63)
BinTree(Stack(Nat))

with Le = s. Models of these types will be interpreted as stacks of binary
trees of natural numbers, respectively binary trees of stacks of natural num-
bers. Clearly what is at issue here is a notion of a type having an input
node and an output node. However, things are not quite so simple, as the
following example shows.

11.2.5 The basic idea of this type is that of n-place records (Pascal) or
structures (C). We leave aside here the use of variant records (which can be
adequately handled by judicious use of ﬁnite sums as C’s union type shows).
Another question we do not tackle is that of parametrizing n. At this point,
we make no attempt to relate the sketches for two-place and three-place
records, say, although it seems clear that in a mature theory this will be
done. Parametrizing n is discussed in [Wagner, 1986b] and [Gray, 1989].

So we describe a sketch we will call Recn. It has nodes r and d1, d2 . . .,

dn and one cone

r

(cid:161)

(cid:64)

(cid:161)

(cid:161)

(cid:161)(cid:170)

d1

· · ·

(cid:64)

(cid:64)

(cid:64)(cid:82)

dn

As it stands, the initial model of this sketch has all values empty. It is really
a shell of a sketch. To give it content, we must ﬁll in values for the data. To
do this we must ﬁrst recognize that the sketch has n input types and these
must all be speciﬁed. This could be done in n steps, but it is more coherent
to do it all at once.

Let En denote the discrete graph with nodes e1, . . . , en. There is an ob-
vious arrow Dn : En −→ Recn given by Dei = di. If, for example, we formed
the pushout

En

(cid:45)Dn

Recn

Fn

(cid:63)
Nat

(cid:45)

(cid:63)
Arrayn

where Fnei = n, i = 1, . . . , n, the resultant sketch can be evidently inter-
preted as arrays of natural numbers. On the other hand, the pushout

11.2 Parametrized data types

319

E3

D3

(cid:45)

Rec3

(cid:63)
Nat +String + Real

(cid:63)
P(cid:45)

(where we suppose that sketches for String and Real have already been
deﬁned) is a sketch for three-place records, of which the ﬁrst ﬁeld is natural
numbers, the second is strings and the third is ﬂoating point reals.

The ideas in this section are discussed without the explicit use of sketches
in [Thatcher, Wagner and Wright, 1982], [Ehrig et al., 1984] and [Wagner,
1986b].

11.2.6 Parametrizing operations The sketch E in the upper left corner
of the pushout diagrams can contain operations. For example, let Nat+
denote the sketch for natural numbers with an added operation + : n ×
n −→ n with diagrams forcing it to be addition in the initial model, and
Nat∗ a similar sketch with an added operation ∗ : n × n −→ n forced to be
multiplication there. Let Diag be the sketch whose graph contains operations

∆

−−→ n × n

m
−−→ n

n

a cone with arrows pi : n × n −→ n, i = 1, 2, to force n × n to be the indicated
product and a diagram to force ∆ to be the diagonal map in a model. Let
BinOp be the sketch containing n × n −→ n and similar data making n × n
the indicated product. BinOp is included in both Diag and in each of Nat+
and Nat∗. A pushout

BinOp

N(cid:45)

(cid:63)
Diag

(cid:63)
P(cid:45)

with N = Nat+ would add a doubling operator to Nat+ and with N = Nat∗
would add a squaring operator to Nat∗.

11.2.7 Arithmetic One last, more speculative example will show that we
have barely begun to explore this idea. Let us suppose that we have deﬁned
two sketches called Real and Complex that implement the arithmetic op-
erations (addition, subtraction, multiplication and division) of real and com-
plex numbers, respectively, as well as absolute value. While it is true that

320

The category of sketches

real numbers are a special case of complex numbers and therefore do not, in
principle, have to be treated diﬀerently, it is also true that real arithmetic
is much easier and faster and virtually every language that implements a
complex number type treats them separately.

Suppose, further, there is a sketch Trig whose operations implement the
trigonometric functions by means of power series or other approximations
which have the same algorithm for real and for complex numbers. This sketch
will use four formal arithmetic operations on an abstract data type d which
admits the arithmetic operations and absolute value, but is not otherwise
speciﬁed. These ﬁve operations are determined by a sketch Arith which has
an arrow to all of Real, Complex, Trig.

If we now form the pushout

Arith

(cid:45)

Real

(cid:63)
Trig

(cid:45)

(cid:63)

RealTrig

we get a sketch for the real type with trigonometric functions and if we
replace Real by Complex, we get a sketch for complex trigonometry.

11.2.8 Exercise

1. If S is the pushout of Diagram (11.1), describe precisely the nodes in S
which must become a singleton in a model in Set.

11.3 The model category functor

Sketch is a category whose objects are sketches. If C is a ﬁxed category, then
each sketch produces a category of models of the sketch in C (see 7.4.4). The
category of models in C of a sketch S we will call ModC (S ). (ModC (S )
might very well be the empty category.)

Most of the examples in this book have had C = Set, which regrettably ob-
scures one of the major advantages sketches have over standard logical theories:
the fact that their models can be in any suitable category.

11.3.1 For each sketch homomorphism F : S −→ T we will now describe a
functor ModC (F ) : ModC (T ) −→ ModC (S ) (note the reversal). ModC (F )
is also denoted F ∗, and is called the functor induced by F . F ∗ is deﬁned
by MF–1 and MF–2 below. If M is a model of T then F ∗(M ) is a model of
S .

11.3 The model category functor

321

MF–1 The object function of F ∗ is deﬁned by F ∗(M ) = M ◦ F . Thus if g
is a node or arrow of the graph of S and M is a model of T , then
F ∗(M )(g) = M (F (g)).

MF–2 If α : M −→ N is a homomorphism of models of T , deﬁne F ∗(α) to
be the natural transformation αF as deﬁned in Section 4.4. Thus at
a node g of the graph of S ,

F ∗(α)(g) = (αF )g = αF (g) : M (F (g)) −→ N (F (g))

11.3.2 Proposition For each model M of T and homomorphism F : S
−→ T , F ∗(M ) is a model of S .

Proof. Since M is among other things a graph homomorphism and so is
F , and the composite of graph homomorphisms is a graph homomorphism,
MF–1 makes F ∗(M ), which is M ◦ F , respect the source and target of arrows
of the graph, so that it is a graph homomorphism to C as a model should
be.

If D is a diagram of S , then because F is a homomorphism of sketches,
F ◦ D is a diagram of T . Since M is a model of T , F ∗(M ) ◦ D = M ◦ F ◦ D
commutes.

Suppose v −→ D is a cone of S . Then F (v) −→ F ◦ D is a cone of T which
must be taken to a limit cone by M . Since F ∗(M )(v −→ D) = M (F (v))
−→ M ◦ F ◦ D, F ∗(M ) takes v −→ D to a limit cone. A similar argument
deals with cocones.

11.3.3 Proposition For each homomorphism α : M −→ N of models of
T and homomorphism F : S −→ T of sketches, ModC (F )(α) as deﬁned
by MF–2 is a homomorphism of models of S .

Proof. By MF–2, F ∗(α) is the natural transformation αF deﬁned in 4.4.1.
Since its domain and codomain are models, it is a homomorphism of models
by deﬁnition.

For any sketch S , let ModC (S ) be the category of models of S in C (we
called this Mod(S , C ) in Section 10.1. If F : S −→ T is a homomorphism of
sketches, we have deﬁned a functor ModC (F ) : ModC (T ) −→ ModC (S ).

11.3.4 Proposition ModC : Sketchop −→ Cat is a functor.

The proof involves some simple checking and is left as an exercise.

322

The category of sketches

11.3.5 Example In Section 3.1, we gave several examples of underlying
set functors U : C −→ Set. In general, such functors are induced by a homo-
morphism of sketches from the trivial sketch E deﬁned in 11.1.2 to a partic-
ular node of the sketch C . For example, the underlying set functor U : Sem
−→ Set (see 3.1.8) is induced by the unique sketch homomorphism from E
to the sketch for semigroups that takes the only node of E to s. This follows
directly from MF–1 and MF–2 and the fact that a model of E in Set is
essentially a set (Exercise 1 of Section 11.2). Similarly the underlying arrow
and node functors A : Grf −→ Set and N : Grf −→ Set (see 3.1.9) are in-
duced by the sketch homomorphisms from E to the sketch for graphs that
take e to a and to n respectively.

11.3.6 Example The sketch homomorphism of Example 11.1.3 induces
the functor from the category of graphs to the arrow category of Set that
takes a graph to its source function. The homomorphism of Example 11.1.4
that includes the sketch for graphs into the sketch for simple graphs induces
the underlying functor that forgets that a graph is simple. Similarly the
functor of 11.1.5 that includes the sketch for semigroups into the sketch for
ﬁelds induces the underlying functor from ﬁelds to semigroups that takes a
ﬁeld to its additive semigroup.

11.3.7 Example Sketches usually include only the minimal information
that is needed to describe a theory. There is a cost to this in that they may
omit crucial information needed to deﬁne morphisms. Here is an uncontrived
example that illustrates the point. We begin by observing that in any cate-
gory, if 1 is a terminal object (vertex of a cone with empty base) and S × S
is a product of two copies of S, then the square

S × S

S(cid:45)

(cid:63)
S

(cid:63)

1(cid:45)

is a pullback. Now consider the functor from the category Mon of mon-
oids to the category Cat of small categories that takes a monoid to the
corresponding category with one object (see 2.3.12). One expects that this
functor would be induced by a sketch homomorphism from the sketch for
categories given by 10.1.5 to the sketch for monoids given by 7.2.1 as aug-
mented by 7.3.2. Since the underlying set of the monoid is the set of arrows
of the corresponding category, the sketch homomorphism should take the
node c1 of 10.1.5 to the node s of 7.2.1, and the arrow c of 10.1.5 (which
we will call comp here to avoid confusion) should go to the multiplication

11.3 The model category functor

323

c of 7.2.1. Since comp has domain c2 and c has domain s × s, c2 should go
to s × s. Unfortunately, s × s is the vertex of a discrete cone and c2 is the
vertex of a pullback cone. And besides, where should c0 go?

The key is to map c0 to the object 1 of the sketch for monoids, so that s
and t are forced to go to the unique map from s to 1. This would force the
pullback cone

c2

p1
(cid:161)

(cid:161)(cid:170)

(cid:161)

(cid:161)

(cid:64)

(cid:64)

(cid:63)
c0(cid:45)

(cid:190)

t

s

p2
(cid:64)

(cid:64)(cid:82)

c1

c1

to go to the cone

s × s

(cid:161)

(cid:161)

(cid:64)

p1
(cid:161)

(cid:161)(cid:170)

(cid:64)

p2
(cid:64)

(cid:64)(cid:82)

(cid:63)

s

s

(cid:190)

1(cid:45)
which unfortunately is not a cone in the sketch for monoids. However, it is
a cone in the FL theory for the sketch for monoids, so it would appear that,
although we cannot realize the functor in question as induced by a sketch
homomorphism from the sketch for categories to the sketch for monoids, it
is nevertheless induced by a homomorphism to a sketch – the underlying
sketch of the theory of monoids.

It is clear that, as the preceding example illustrates, one would normally
want to consider homomorphisms of theories (functors that preserve ﬁnite
limits in this case) rather than homomorphisms of sketches. In practice,
one would construct a homomorphism from a sketch S to the theory of a
sketch T since such a homomorphism would extend essentially uniquely to a
mapping between theories. An alternative would be to adjoin just what you
need to T to make the homomorphism work (the cone of Diagram (11.3.7)
– and others – in this case), but that seems excessively clumsy when the
whole theory exists in any case.

11.3.8 It is almost immediate that Propositions 11.3.2, 11.3.3 and 11.3.4
remain true if the category Sketch is replaced by the category of sketches
with diagrams based on a speciﬁc class of shape graphs, cones to speciﬁc
class of shape graphs not necessarily the same as that of the diagrams, and
cocones from a speciﬁc class of shape graphs not necessarily the same as
either of the other two. For example, taking any shapes for the diagrams,
ﬁnite discrete shapes for the cones, and no shapes for the cocones gives the

324

The category of sketches

category of FP sketches and homomorphisms between them, so all these
propositions are true of FP sketches.

11.3.9 Sentences For this subsection only, we will say a sentence in a
sketch S is a diagram, cone or cocone in the graph of S , not necessarily one
in the speciﬁed set of diagrams, cones or cocones. The sentence is satisﬁed
in a model M of S if it commutes when M is applied (if it is a diagram) or
if it is a (co)limit (co)cone when M is applied (if it is a (co)cone).

If F : S −→ T is a sketch homomorphism, and σ is a sentence of S ,
then F (σ) is a sentence of T where F (σ) is deﬁned by composition: this
follows from the deﬁnition of sketch homomorphism.

11.3.10 Proposition If F : S −→ T is a sketch homomorphism and σ
is a sentence of S , then F (σ) is satisﬁed in a model M of T in a category
C if and only if σ is satisﬁed in ModC (F )(M ).

This follows directly from the deﬁnitions and is left as an exercise.
Propositions 11.3.4 and 11.3.10 imply that the category of sketches with
designated shape graphs for each of the diagrams, cones and cocones, to-
gether with sentences, form a ‘simple institution’ in the sense of [Goguen
and Burstall, 1986].

11.3.11 The results of this section show the way in which sketches are
a very diﬀerent method for describing mathematical structures from the
theories of traditional mathematical logic. Of course, sketches use graphs,
diagrams, cones and cocones instead of variables, symbols, expressions and
formulas, but that diﬀerence, although signiﬁcant, is not the biggest dif-
ference. When you use sketches, you factor the entire descriptive process
diﬀerently. We have already discussed the diﬀerences to some extent for FP
sketches in 7.2.8.

An example of the subtlety of the diﬀerence is exempliﬁed by our word
‘sentence’ above. Diagrams correspond to universally quantiﬁed sentences,
and the correspondence, which is not entirely trivial (see Section 7.7), is
nevertheless exact. But to use a cone as a sentence corresponds to a state-
ment about a type in multisorted logic, rather than statements about terms.
(McLarty [1986] makes this explicit.) Such statements have not played a big
role in classical logic. In classical logic, you do not say (with an axiom) that
a type is (for example) a product type; the product type is implicit in the
existence of some given term which has a sequence of variables of speciﬁc
types.

On the other hand, our sentences do not provide a way of giving universal
Horn clauses in (for example) an FL sketch. When using sketches, universal
Horn clauses are usually implicit. Such a clause which must be satisﬁed in

11.3 The model category functor

325

all models is given by an arrow built into the graph of the sketch which
causes an operation to factor through some limit type. Thus if you wanted
to require

a = b ⇒ g(f (a, b)) = h(f (a, b))

where a and b are of type A, f is an operation of type C and g and h
are operations of type D, you build the graph of your sketch with arrows
f : A × A −→ C, g, h : C −→ D, e : E −→ C, u : A −→ E and d : A −→ A × A,
with cones requiring A × A to be the required product, e to be the equalizer
of g and h, d to be the diagonal map, and this diagram

A

(cid:45)d

A × A

u

f

(cid:63)
E

(cid:63)

C(cid:45)

e

which requires f ◦ d to factor through the equalizer of g and h. It is built
into the graph in a way analogous to the way in classical logic you build the
product types implicitly by incorporating speciﬁc terms.

There is presumably a theory of sentences built in this way which makes
FL sketches an institution, but it will require work to produce it: it does not
ﬁt well with the ingredients of a sketch. In the same way, building an insti-
tution out of classical logic using a deﬁnition of sentence which allows you
to state that a type is a certain equalizer or pullback requires work because
it does not ﬁt the traditional way of doing things. (It is not impossible, it
merely does not ﬁt well.) The classical approach and the sketch approach
make diﬀerent things easy.

11.3.12 Exercises

1. In Example 4.3.6 we deﬁned a functor U × U : Mon −→ Set. Show that
it is induced by a homomorphism of sketches.

2. Prove that MF–2 makes F ∗ a natural transformation.

3. Prove Proposition 11.3.4.

4. Prove Proposition 11.3.10.

12
Fibrations

A category is both a generalized poset and a generalized monoid. Many con-
structions in category theory can be understood in terms of the constructions
in posets that they generalize, so that it is generally good advice when learn-
ing about a new categorical idea to see what it says about posets. Seeing
what a construction says about monoids has not usually been so instructive.
However, certain concepts used to study the algebraic structure of mon-
oids generalize to categories in a natural way, and often the theorems about
them remain true. In addition, applications of monoids to the theory of au-
tomata have natural generalizations to categories, and some work has been
done on these generalized ideas.

In this chapter we describe some aspects of categories as generalized
monoids. We begin in Section 12.1 with the concept of ﬁbration, which has
been used in recent research on polymorphism. One way of constructing
ﬁbrations is by the Grothendieck construction, described in Section 12.2,
which is a generalization of the semidirect product construction for mon-
oids. Section 12.3 gives an equivalence between certain types of ﬁbrations
and category-valued functors. Section 12.4 describes the wreath product of
categories, a generalization of the concept of the same name for monoids;
some applications of the construction are mentioned.

The Grothendieck construction is used in Section 15.7. The rest of the

material is not used elsewhere in the book.

12.1 Fibrations

In this section, we describe ﬁbrations, which are special types of functors
important in category theory and which have been proposed as useful in
certain aspects of computer science.

The next section gives a way of constructing ﬁbrations from set or category-

valued functors.

12.1.1 Fibrations and opﬁbrations Let P : E −→ C be a functor be-
tween small categories, let f : C −→ D be an arrow of C , and let P (Y ) = D.
An arrow u : X −→ Y of E is cartesian for f and Y if

CA–1 P (u) = f .

327

328

Fibrations

CA–2 For any arrow v : Z −→ Y of E and any arrow h : P (Z) −→ C of C
for which f ◦ h = P (v), there is a unique w : Z −→ X in E such that
u ◦ w = v and P (w) = h.

Similarly, if f : C −→ D and P (X) = C, then an arrow u : X −→ Y is

opcartesian for f and X if

OA–1 P (u) = f .
OA–2 For any arrow v : X −→ Z of E and any arrow k : D −→ P (Z) for
which k ◦ f = P (v), there is a unique w : Y −→ Z in E for which
w ◦ u = v and P (w) = k.

If P : E −→ C is a functor, categorists often think of E as being above C .
(This is also common for functions between spaces, which is what originally
suggested the ideas in this section.) For example, if P (Y ) = D, one says that
Y lies over D. Similar terminology is used for arrows. Thus a cartesian arrow
for f must lie over f (CA–1) and one refers to CA–2 as a ‘unique lifting’
property.

12.1.2 Deﬁnition A functor P : E −→ C is a ﬁbration if there is a carte-
sian arrow for every f : C −→ D in C and every object Y of E for which
P (Y ) = D. P is an opﬁbration if there is an opcartesian arrow for every
f : C −→ D in C and every object X of E for which P (X) = C. It follows that
P : E −→ C is a ﬁbration if and only if P op : E op −→ C op is an opﬁbration.
If P : E −→ C is a ﬁbration, one also says that E is ﬁbered over C .
In that case, C is the base category and E is the total category of the
ﬁbration.

12.1.3 Deﬁnition A cleavage for a ﬁbration P : E −→ C is a function γ
that takes an arrow f : C −→ D and object Y such that P (Y ) = D to an
arrow γ(f, Y ) of E that is cartesian for f and Y . Similarly an opcleavage κ
takes f : C −→ D and X such that P (X) = C to an arrow κ(f, X) that is
opcartesian for f and X.

The cleavage γ is a splitting of the ﬁbration if it satisﬁes the following

two requirements.

SC–1 Let D be an object of C and let Y be an object of E for which

P (Y ) = D. Then γ(idD, Y ) = idY .

SC–2 Suppose f : C −→ D and g : D −→ E in C and suppose Y and Z are
objects of E for which P (Z) = E and Y is the domain of γ(g, Z). Then

γ(g, Z) ◦ γ(f, Y ) = γ(g ◦ f, Z)

12.1 Fibrations

329

Note that under the assumptions in SC–2, P (Y ) = D, so that γ(f, Y )

and γ(g, Z) ◦ γ(f, Y ) are deﬁned.

A ﬁbration is split if it has a splitting.
Similarly, an opcleavage κ is a splitting of an opﬁbration P : E −→ C if

κ(idC, X) = idX whenever P (X) = C and

κ(g, Y ) ◦ κ(f, X) = κ(g ◦ f, X)

whenever f : C −→ D and g : D −→ E in C , P (X) = C and Y is the codomain
of κ(f, X). A split opﬁbration is again one which has a splitting.

12.1.4 Example Let A and C be any categories. Then the second projec-
tion p2 : A × C −→ C is both a split ﬁbration and a split opﬁbration. To see
that it is a ﬁbration, suppose that f : C −→ C(cid:48) in C and let Y = (A, C(cid:48)) be an
object of A × C . Then we can take γ(f, Y ) to be the arrow (idA, f ) : (A, C)
−→ (A, C(cid:48)). If (g, h) : (A(cid:48), C(cid:48)(cid:48)) −→ (A, C(cid:48)) and u : C(cid:48)(cid:48) −→ C satisfy f ◦ u = h
(note that p2(g, h) = h), then the unique arrow from (A(cid:48), C(cid:48)(cid:48)) to (A, C(cid:48))
required by CA–2 is (g, u).

12.1.5 Example
If C is a category, the arrow category of C (which we
have already mentioned in 4.2.17) has as objects the arrows of C . An arrow
from f : A −→ B to g : C −→ D is a pair (h, k) of arrows with h : A −→ C,
k : B −→ D for which

C(cid:45)h

A

f

g

(12.1)

(cid:63)
B

(cid:63)
D(cid:45)

k

commutes.

If A is the arrow category of C , there is a functor P : A −→ C which
takes f : A −→ B to B and (h, k) : f −→ g to k. If C has pullbacks, this
functor is a ﬁbration. For a given f : C −→ D in C and object k : B −→ D of
A , a cartesian arrow for f and k is any (u, f ) given by a pullback

P

B(cid:45)u

u(cid:48)

(cid:63)
C

k
(cid:63)
D(cid:45)

f

(12.2)

The veriﬁcation is left as an exercise (Exercise 4).

330

Fibrations

12.1.6 Fibers For any functor P : E −→ C , the ﬁber over an object C of
C is the set of objects X for which P (X) = C and arrows f for which P (f ) =
idC. It is easy to verify that this ﬁber is a subcategory of E (Exercise 1).

In the case of Example 12.1.4, the ﬁbers are all the same: each one is iso-
morphic to the category A . This suggests thinking of an arbitrary ﬁbration
as a type of generalized product, in which the ﬁrst coordinates come in gen-
eral from varying sets depending on the second coordinate. This observation
can also be made concerning the relationship between a set product S × T
and a general T -indexed set.

On the other hand, the ﬁber of the ﬁbration in Example 12.1.5 over an
object A of C is the slice category C /A. Since an object of C /A can be
thought of as an indexed family of objects of C , indexed by A, this example
has been referred to as C ‘ﬁbered over itself’.

If E is ﬁbered over C , then the ﬁbers
12.1.7 Cleavages induce functors
form an indexed set of categories (indexed by the objects). Given a cleavage,
the arrows of C induce functors between the ﬁbers. In this way ﬁbrations or
opﬁbrations give a concept like that of indexed sets, in which the indexing
takes into account the arrows of the underlying categories as well as the
objects. Propositions 12.1.8 and 12.1.9 below spell this out.

An alternative approach to these ideas which follows the indexed set
analogy more explicitly is the concept of indexed category (see [John-
stone and Par´e, 1978], [Tarlecki, Burstall and Goguen, 1991]). Rosebrugh
and Wood [1992] apply indexed categories to relational databases and Cock-
ett and Spencer [1992] use them in studying datatypes.

In the rest of this chapter, when F : C −→ Cat or F : C −→ Set is a

functor, we will normally write F f for F (f ).

Let P : E −→ C be an opﬁbration with opcleavage κ. Deﬁne F : C −→

Cat by

FF–1 F (C) is the ﬁber over C for each object C of C .
FF–2 For f : C −→ D in C and X an object of F (C), F f (X) is deﬁned to

be the codomain of the arrow κ(f, X).

FF–3 For f : C −→ D in C and u : X −→ X (cid:48) in F (C), F f (u) is the unique

arrow from F f (X) to F f (X (cid:48)) given by OA–2 for which

F f (u) ◦ κ(f, X) = κ(f, X (cid:48)) ◦ u

12.1.8 Proposition Let P : E −→ C be an opﬁbration with cleavage κ.
For any arrow f : C −→ D in C , F f : F (C) −→ F (D) as deﬁned by FF–1
through FF–3 is a functor. Moreover, if κ is a splitting, then F is a functor
from C to Cat.

12.1 Fibrations

331

Proof. Let u : X −→ X (cid:48) and v : X (cid:48) −→ X (cid:48)(cid:48) in F (C). Then

F f (v) ◦ F f (u) ◦ κ(f, X) = F f (v) ◦ κ(f, X (cid:48)) ◦ u

= κ(f, X (cid:48)(cid:48)) ◦ v ◦ u

(12.3)

by two applications of FF–3. But then by the uniqueness part of FF–3,
F f (v) ◦ F f (u) must be F f (v ◦ u). This proves F f preserves composition.
We leave the preservation of identities to you.

Now suppose κ is a splitting. Let f : C −→ D and g : D −→ E in C ,
and let u : X −→ X (cid:48) in F (C). Then F (g ◦ f )(u) is the unique arrow from
F (g ◦ f )(X) (the codomain of κ(g ◦ f, X)) to F (g ◦ f )(X (cid:48)) (the codomain of
κ(g ◦ f, X (cid:48))) for which

F (g ◦ f )(u) ◦ κ(g ◦ f, X) = κ(g ◦ f, X (cid:48)) ◦ u

Since κ is a splitting, this says

F (g ◦ f )(u) ◦ κ(g, F f (X)) ◦ κ(f, X) = κ(g, F f (X (cid:48))) ◦ κ(f, X (cid:48)) ◦ u

By FF–3, the right side is

κ(g, F f (X (cid:48))) ◦ F f (u) ◦ κ(f, X)

Applying FF–3 with g and F f (u) instead of f and u, this is the same as

which is

F g[F f (u)] ◦ κ(g, F f (X)) ◦ κ(f, X)

F g[F f (u)] ◦ κ(g ◦ f, X)

because κ is a splitting. Using the uniqueness requirement in FF–3, this
means F (g ◦ f )(u) = F g[F f (u)], so that F preserves composition. Again,
we leave preservation of the identity to you.

In a similar way, split ﬁbrations give functors C op −→ Cat. Let P : E

−→ C be a ﬁbration with cleavage γ. Deﬁne F : C op −→ Cat by
FF(cid:48)–1 F (C) is the ﬁber over C for each object C of C .
FF(cid:48)–2 For f : C −→ D in C and Y an object of F (D), F f (Y ) is deﬁned to

be the domain of the arrow γ(f, Y ).

FF(cid:48)–3 For f : C −→ D in C and u : Y −→ Y (cid:48) in F (D), F f (u) is the unique

arrow from F f (Y ) to F f (Y (cid:48)) given by CA–2 for which

γ(f, Y (cid:48)) ◦ F f (u) = u ◦ γ(f, Y )

12.1.9 Proposition Let P : E −→ C be a ﬁbration with cleavage κ. For
any arrow f : C −→ D in C , F f : F (C) −→ F (D) as deﬁned by FF–1 through
FF–3 is a functor. Moreover, if γ is a splitting, then F is a functor from
C op to Cat.

The proof is similar to those of Proposition 12.1.8 and is left as an exer-

cise.

332

Fibrations

12.1.10 Exercises

1. Verify that for any functor P : E −→ C and object C of C , the ﬁber over
an object C is a subcategory of E .

2. Prove Proposition 12.1.9.

3. Let φ : Z4 −→ Z2 be the homomorphism deﬁned in Exercise 2 of Sec-
tion 2.9.

a. Show that the functor from C(Z4) to C(Z2) induced by φ is a ﬁbration
and an opﬁbration. (If you know about groups, this is an instance of the fact
that every surjective group homomorphism is a ﬁbration and an opﬁbration.)

b. Show that φ is not a split ﬁbration or opﬁbration.

4. Let C be a category with pullbacks and A its arrow category. For an
arrow f : A −→ B (object of A ) let P (f ) = B. For an arrow (h, k) : f −→ g
(where g : C −→ D in C ) in A , let P (h, k) = k.

a. Show that P : A −→ C is a functor.
b. Show that P is a ﬁbration.

12.2 The Grothendieck construction

The Grothendieck construction is a way of producing ﬁbrations. It general-
izes the semidirect product construction for monoids, which is deﬁned here.
Hyland and Pitts [1989] use the Grothendieck construction to construct cat-
egories that are models of the calculus of constructions, a system due to
Coquand and Huet [1988] that provides a way of handling polymorphism
essentially by quantifying over types. (See also [Coquand, 1988], [Ehrhard,
1988] and [Asperti and Martini, 1992].)

The construction can be applied to either set-valued functors or category-
valued functors. Given such a functor F : C −→ Set or F : C −→ Cat, it
constructs a category G(C , F ) and a functor from G(C , F ) to C . When F is
set-valued we will write G0 instead of G. We will look at the set-valued case
ﬁrst, since it is simpler.

12.2.1 Let C be a small category and let F : C −→ Set be a functor. For
each object C of C , F (C) is a set, and for each arrow f : C −→ D, F (f ) :
F (C) −→ f (D) is a set function. There is no set of all sets or set of all set
functions, but, since C is small, there certainly is a set consisting of all the
elements of all the sets F (C), and similarly there is a set consisting of all
the functions F (f ). In other words, although Set is large, the description of
F : C −→ Set requires only a small amount of data. (‘Small’ and ‘large’ are
used here in the technical sense, referring to whether or not a set of data is
involved. See 1.3.4.)

12.2 The Grothendieck construction

333

By contrast, to describe a functor G : Set −→ C would require a large amount
of data – an object of C for each set, and so on.

We will formalize these observations about F : C −→ Set by taking the
disjoint union of all the sets of the form F (C) for all objects C of C . The
elements of this disjoint union can be represented as pairs (x, C) for all
objects C of C and elements x ∈ F (C). (Thus we construct the disjoint union
of sets by labeling the elements. The disjoint union is the construction in Set
corresponding to the categorical concept of ‘sum’, discussed in Section 5.4.)
We must do more than this to capture the functorial nature of F – what it
does to arrows of C . The category G0(C , F ) constructed by the Grothendieck
construction does capture this structure, and its set of objects is the disjoint
union just mentioned.

12.2.2 If we were to draw a picture to explain what F does, the result
might be Diagram (12.4), in which f : C −→ C(cid:48) and g : C(cid:48) −→ C(cid:48)(cid:48) are arrows
of C and x and x(cid:48) are elements of F (C) and F (C(cid:48)) respectively. The box

x

C

(cid:45)

F f (x)

(cid:45)

(F g ◦ F f )(x)

(cid:45)F f

f

x(cid:48)

C(cid:48)(cid:45)

(cid:45)F g

(cid:45)

F g(x(cid:48))

g

C(cid:48)(cid:48)(cid:45)

(12.4)

over each object C of C represents the elements of F (C). The arrows from
x to F f (x) and from x(cid:48) to F g(x(cid:48)) are there informally to illustrate what the
set functions F f and F g do. These informal arrows become actual arrows in
G0(C , F ).

12.2.3 Deﬁnition G0(C , F ) is the category deﬁned as follows.

GS–1 An object of G0(C , F ) is a pair (x, C) where C is an object of C and
x is an element of F (C) (as observed, the C occurs in the pair (x, C)
because we want the disjoint union of the values of F ).

GS–2 An arrow is a pair of the form (x, f ) : (x, C) −→ (x(cid:48), C(cid:48)) where f is an

arrow f : C −→ C(cid:48) of C for which F f (x) = x(cid:48).

334

Fibrations

GS–3 If (x, f ) : (x, C) −→ (x(cid:48), C(cid:48)) and (x(cid:48), g) : (x(cid:48), C(cid:48)) −→ (x(cid:48)(cid:48), C(cid:48)(cid:48)), then

(x(cid:48), g) ◦ (x, f ) : (x, C) −→ (x(cid:48)(cid:48), C(cid:48)(cid:48)) is deﬁned by

(x(cid:48), g) ◦ (x, f ) = (x, g ◦ f )

Note in GS–3 that indeed F (g ◦ f )(x) = x(cid:48)(cid:48) as required by GS–2.
The reason that we use the notation (x, f ) is the requirement that an
arrow must determine its source and target. The source of (x, f ) is (x, C),
where C is the source of f and x is explicit, while its target is (x(cid:48), C(cid:48)), where
C(cid:48) is the target of f and x(cid:48) = F f (x). In the literature, (x, f ) is often denoted
simply f , so that the same name f may refer to many diﬀerent arrows – one
for each element of F (C). We used lacunary notation of this sort in deﬁning
slice categories in 2.6.10.

Projection on the second coordinate deﬁnes a functor

G0(F ) : G0(C , F ) −→ C

G0(C , F ) together with G0(F ) is called the split discrete opﬁbration
induced by F , and C is the base category of the opﬁbration.

If C is an object of C , the inverse image under G0(F ) of C is simply the
set F (C), although its elements are written as pairs so as to form a disjoint
union.

This discrete opﬁbration is indeed an opﬁbration, in fact a split opﬁ-
bration. If f : C −→ C(cid:48) in C and (x, C) is an object of G0(C , F ), then an
opcartesian arrow is (x, f ) : (x, C) −→ (F f (x), C(cid:48)) (Exercise 2). The word
‘discrete’ refers to the fact that the ﬁbers are categories in which the only
arrows are identity arrows; such categories are essentially the same as sets.

12.2.4 Semidirect products We now describe a more general version of
the Grothendieck construction that has the semidirect product of monoids
as a special case. We ﬁrst deﬁne the semidirect product of monoids: it is
constructed from two monoids, one of which acts on the other.

12.2.5 Deﬁnition If M and T are monoids, an action of M on T is a
function α : M × T −→ T for which

MA–1 α(m, 1T ) = 1T for all m ∈ M .
MA–2 α(m, tu) = α(m, t)α(m, u) for all m ∈ M and t, u ∈ T .
MA–3 α(1M , t) = t for all t ∈ T .
MA–4 α((mn), t) = α(m, α(n, t)) for all m, n ∈ M and t ∈ T .

If we curry α as in 6.1.2, we get a family of functions φ(m) : T −→ T with

the properties listed in MA(cid:48)–1 through MA(cid:48)–4 below.
MA(cid:48)–1 φ(m)(1T ) = 1T for all m ∈ M .

12.2 The Grothendieck construction

335

MA(cid:48)–2 φ(m)(tu) = φ(m)(t)φ(m)(u) for all m ∈ M and t, u ∈ T .
MA(cid:48)–3 φ(1M )(t) = t for all t ∈ T .
MA(cid:48)–4 φ(mn)(t) = φ(m)[φ(n)(t)] for all m, n ∈ M and t ∈ T .

Thus we see that an alternative formulation of monoid action is that it
is a monoid homomorphism φ : M −→ End(T ) (End(T ) being the monoid
of endomorphisms of T ). MA(cid:48)–1 and MA(cid:48)–2 say that each function φ(m)
is an endomorphism of T , and MA(cid:48)–3 and MA(cid:48)–4 say that φ is a monoid
homomorphism.

12.2.6 Deﬁnition The semidirect product of M and T with the given
action α as just deﬁned is the monoid with underlying set T × M and mul-
tiplication deﬁned by

(t, m)(t(cid:48), m(cid:48)) = (tα(m, t(cid:48)), mm(cid:48))

To see the connection with the categorical version below you may wish

to write this deﬁnition using the curried version of α.

12.2.7 The categorical construction corresponding to a monoid acting on a
monoid is a functor which takes values in Cat rather than in Set. A functor
F : C −→ Cat can be regarded as an action of C on a variable category which
plays the role of T in the deﬁnition just given.

In the case of a monoid action deﬁned by MA–1 through MA–4, the
variable category is actually not varying: it is the category C(T ) determined
by the monoid T . The functor F in that case takes the single object of
M to the single object of T , and, given an element m ∈ M , F (m) is the
endomorphism of T which takes t ∈ T to mt: in other words, F (m)(t) = mt.
Thus F on the arrows is the curried form of the action α.

A set-valued functor is a special case of a category-valued functor, since a
set can be regarded as a category with only identity arrows. Note that this is
diﬀerent from the monoid case: an action by a monoid on a set is not in general
a special case of an action by the monoid on a monoid. It is, however, a special
case of the action of a monoid on a category – a discrete category.

12.2.8 Given a functor F : C −→ Cat, the Grothendieck construction in
this more general setting constructs the opﬁbration induced by F , a category
G(C , F ) deﬁned as follows:

GC–1 An object of G(C , F ) is a pair (x, C) where C is an object of C and

x is an object of F (C).

336

Fibrations

GC–2 An arrow (u, f ) : (x, C) −→ (x(cid:48), C(cid:48)) has f : C −→ C(cid:48) an arrow of C and
u : F f (x) −→ x(cid:48) an arrow of F (C(cid:48)) (note that by deﬁnition F f (x) is
an object of F (C(cid:48))).

GC–3 If (u, f ) : (x, C) −→ (x(cid:48), C(cid:48)) and (v, g) : (x(cid:48), C(cid:48)) −→ (x(cid:48)(cid:48), C(cid:48)(cid:48)), then (v, g) ◦

(u, f ) : (x, C) −→ (x(cid:48)(cid:48), C(cid:48)(cid:48)) is deﬁned by

(v, g) ◦ (u, f ) = (v ◦ F g(u), g ◦ f )

12.2.9 Theorem Given a functor F : C −→ Cat, G(C , F ) is a category
and the second projection is a functor P : G(C , F ) −→ C which is a split
opﬁbration with splitting

κ(f, X) = (idF f x, f ) : (x, C) −→ (F f x, C(cid:48))

for any arrow f : C −→ C(cid:48) of C and object (x, C) of G(C , F ).

We omit the proof of this theorem. G(C , F ) is called the crossed prod-

uct C × F by some authors.

It is instructive to compare this deﬁnition with the discrete opﬁbration
constructed from a set-valued functor. In the case that F is set-valued,
the ﬁrst component u of an arrow (u, f ) : (x, C) −→ (x(cid:48), C(cid:48)) has to be an
identity arrow and it has to be idF f (x). Thus the only arrows are of the
form (idF f (x), f ) : (x, C) −→ (x(cid:48), C). Such an arrow is denoted (x, f ) in GS–1
through GS–3.

To visualize the Cat-valued Grothendieck construction, we can modify
the picture in Diagram (12.4) to get Diagram (12.5). The arrows from inside

x

C

(cid:45)

F f (x)

(cid:45)

(F g ◦ F f )(x)

(cid:45)F f

u

(cid:63)
x(cid:48)

(cid:45)F g

F g(u)

(12.5)

(cid:63)
F g(x(cid:48))

(cid:45)

f

C(cid:48)(cid:45)

g

C(cid:48)(cid:48)(cid:45)

one box to inside another, such as the arrow from x to F f (x), are parts
of arrows of G(f ), which are now (in contrast to the discrete case) allowed
to miss the target and be rescued by an internal arrow of the codomain
category.

12.2 The Grothendieck construction

337

Thus in the picture above there is an arrow from x to F f (x) and F f (x)
is not necessarily x(cid:48); the gap is ﬁlled by the arrow u : F f (x) −→ x(cid:48) of F (C(cid:48)).
The arrow (u, f ) : (x, C) −→ (x(cid:48), C(cid:48)) of G(C , F ) may be pictured as the arrow
from x to F f (x) followed by u. Observe that the deﬁnition of composition
says that the square in the picture with corners F f (x), (F g ◦ F f )(x), x(cid:48) and
F g(x(cid:48)) ‘commutes’.

As before, one writes (x, C) for x and (x(cid:48), C(cid:48)) for x(cid:48) only to ensure that

the union of all the categories of the form F (C) is a disjoint union.

12.2.10 An analogous construction, also called the Grothendieck construc-
tion (in fact this is the original one), produces a split ﬁbration F(C , G) given
a functor G : C op −→ Cat.

FC–1 An object of F(C , G) is a pair (C, x) where C is an object of C and x

is an object of G(C).

FC–2 An arrow (f, u) : (C, x) −→ (C(cid:48), x(cid:48)) has f : C −→ C(cid:48) an arrow of C and

u : x −→ Gf (x(cid:48)) an arrow of G(C).

FC–3 If (f, u) : (C, x) −→ (C(cid:48), x(cid:48)) and (g, v) : (C(cid:48), x(cid:48)) −→ (C(cid:48)(cid:48), x(cid:48)(cid:48)), then the

composite (g, v) ◦ (f, u) : (C, x) −→ (C(cid:48)(cid:48), x(cid:48)(cid:48)) is deﬁned by

(g, v) ◦ (f, u) = (g ◦ f, Gf (v) ◦ u)

12.2.11 In line with the concept that a category is a mathematical work-
space, one could ask to construct objects in a suitably rich category which
themselves are categories. The Grothendieck construction provides a way to
describe functors from such a category object to the ambient category which
is worked out in 15.7.2.

12.2.12 Exercises

1. Verify that GS–1 through GS–3 deﬁne a category.

2. Show that for any functor F : C −→ Set, G0(F ) : G0(C , F ) −→ C is a split
opﬁbration.

3. Verify that GC–1 through GC–3 deﬁne a category.

4. Show that for any functor F : C −→ Cat, G(F ) : G(C , F ) −→ C is a split
opﬁbration.

5. Verify that the deﬁnition of the semidirect product in 12.2.6 makes T × M
a monoid.

6. Let F : C −→ Cat be a functor. Show that for each object C of C , the
arrows of the form (u, idC) : (x, C) −→ (y, C) (for all arrows u : x −→ y of
F (C)) (and their sources and targets) form a subcategory of the opﬁbration
G(C , F ) which is isomorphic to F (C).

338

Fibrations

12.3 An equivalence of categories

In this section, we describe how the construction of a functor from an opﬁbra-
tion given in Proposition 12.1.8 (in one direction) produces an equivalence of
categories (with the Grothendieck construction as pseudo-inverse) between
a category of functors and a suitably deﬁned category of split opﬁbrations.

12.3.1 Cat-valued functors For a category C , Func(C , Cat) is the cat-
egory whose objects are functors from C to the category of categories, and
whose arrows are natural transformations between them.

If F : C −→ Cat is such a functor and f : C −→ D is an arrow of C , then
F (C) and F (D) are categories and F f : F (C) −→ F (D) is a functor. If also
G : C −→ Cat and α : F −→ G is a natural transformation, then for each
object of C, αC : F (C) −→ G(C) is a functor and the following diagram is a
commutative diagram of categories and functors:

F (C)

(cid:45)αC

G(C)

F f

(cid:63)
F (D)

Gf

(cid:63)
G(D)

(cid:45)

αD

(12.6)

12.3.2 The category of split opﬁbrations of C Let P : E −→ C and
P (cid:48) : E (cid:48) −→ C be two split opﬁbrations of the same category C with splittings
κ and κ(cid:48) respectively. A homomorphism of split opﬁbrations is a functor
ζ : E −→ E (cid:48) for which

HSO–1 The diagram

E

(cid:64)
P

(cid:64)

E (cid:48)(cid:45)
(cid:161)
P (cid:48)

(cid:161)

ζ

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

C

(12.7)

commutes.

HSO–2 For any arrow f : C −→ D in C and object X of E such that P (X) =

C,

ζ(κ(f, X)) = κ(cid:48)(f, ζ(X))

Thus a homomorphism of split ﬁbrations ‘takes ﬁbers to ﬁbers’ and ‘preserves
the splitting’.

12.3 An equivalence of categories

339

12.3.3 Deﬁnition Split opﬁbrations of C and homomorphisms between
them form a category SO(C ).

We will show that SO(C ) is equivalent to Func(C , Cat). We do this by

deﬁning two functors

and

F : SO(C ) −→ Func(C , Cat)

G : Func(C , Cat) −→ SO(C )

so that F is an equivalence with pseudo-inverse G as deﬁned in Section 3.4.

12.3.4 Deﬁnition For a category C , deﬁne the functor

F : SO(C ) −→ Func(C , Cat)

as follows:

FI–1 If P : E −→ C is a split opﬁbration with splitting κ, then F(P, κ) : C −→
Cat is the functor F satisfying FF–1 through FF–3 deﬁned in 12.1.7.
FI–2 If ζ : (P, κ) −→ (P (cid:48), κ(cid:48)) is a homomorphism of opﬁbrations, Fζ : F(P, κ)
−→ F(P (cid:48), κ(cid:48)) is the natural transformation whose component at an
object C of C is the functor ζ restricted to P −1(C).

To show that F ζ is a natural transformation, it is necessary to show that

for every f : C −→ D in C the following diagram commutes:

F(P, κ)(C)

(cid:45)FζC

F(P (cid:48), κ(cid:48))(C)

F(P, κ)(f )

(cid:63)
F(P, κ)(D)

(cid:45)

FζD

F(P (cid:48), κ(cid:48))(f )
(cid:63)
F(P (cid:48), κ(cid:48))(D)

(12.8)

Let u : X −→ X (cid:48) be in F(P, κ)(C). Note that u is an arrow in the inverse
image P −1C, so P u = idC. Moreover, ζu is an arrow for which P (cid:48)(ζu) = idC.
By deﬁnition of cleavage, there are unique arrows (cid:101)u such that P ((cid:101)u) = idD

and (cid:98)u such that P (cid:48)((cid:98)u) = idD, for which

(cid:101)u ◦ κ(f, X) = κ(f, X (cid:48)) ◦ u

and

(cid:98)u ◦ κ(cid:48)(f, ζ(X)) = κ(f, ζ(X (cid:48))) ◦ ζu

340

Fibrations

The top route in Diagram (12.8) takes u to (cid:98)u and the bottom route takes it
to ζ (cid:101)u. The following calculation shows that the diagram commutes:

(cid:98)u ◦ κ(cid:48)(f, ζ(X)) = κ(cid:48)(f, ζ(X (cid:48))) ◦ ζ(u)
= ζ(κ(f, X (cid:48))) ◦ ζ(u)
= ζ(κ(f, X (cid:48)) ◦ u)
= ζ((cid:101)u ◦ κ(f, X))
= ζ((cid:101)u) ◦ ζ(κ(f, X))
= ζ((cid:101)u) ◦ κ(cid:48)(f, ζ(X))

(12.9)

so that (cid:98)u = ζ((cid:101)u) by the uniqueness requirement in the deﬁnition of (cid:98)u.

12.3.5 The Grothendieck functor To deﬁne the functor going the other
way we extend the Grothendieck construction.

12.3.6 Deﬁnition For a category C , deﬁne the functor

G : Func(C , Cat) −→ SO(C )

as follows:

GR–1 For F : C −→ Cat, G(F ) = G(C , F ).
GR–2 For a natural transformation α : F −→ G : C −→ Cat,

Gα(x, C) = (αCx, C)

for (x, C) an object of G(C , F ) (so that C is an object of C and x is
an object of F C), and

Gα(u, f ) = (αC(cid:48)u, f )

for (u, f ) an arrow of G(C , F ) (so that f : C −→ C(cid:48) in C and u : F f x
−→ x(cid:48) in F C(cid:48)).

Note that in GR–2, αC(cid:48)u has domain αC(cid:48)(F f x), which is Gf (αCx)
because α is a natural transformation. The veriﬁcation that Gα is a functor
is omitted.

12.3.7 Theorem The functor F : SO(C ) −→ Func(C , Cat) deﬁned in 12.3.4
is an equivalence of categories with pseudo-inverse G.

There is a similar equivalence of categories between split ﬁbrations and
contravariant functors. The details are in [Nico, 1983]. Moreover, the non-
split case for both ﬁbrations and opﬁbrations corresponds in a precise way
to ‘pseudo-functors’, which are like functors except that identities and com-
posites are preserved only up to natural isomorphisms. See [Gray, 1966] (the
terminology has evolved since that article). A generalization of this equiva-
lence is described in [Pavlovi´c and Abramsky, 1997], page 151, with references
to the literature for other generalizations.

12.4 Wreath products

341

12.3.8 Exercises

1. Verify that Gα as deﬁned by GR–2 is a functor.

2. Verify that G as deﬁned by GR–1 and GR–2 is a functor.

12.4 Wreath products

In this section, we introduce the idea of the wreath product of categories (and
of functors), based on an old construction originating in group theory. In the
monoid case, this construction allows a type of series-parallel decomposition
of ﬁnite state machines (the Krohn–Rhodes Theorem). This section is not
needed later.

12.4.1 Let A and B be small categories and G : A −→ Cat a functor.
With these data we deﬁne the shape functor S(G, B) : A op −→ Cat as
follows. If A is an object of A , then S(G, B)(A) is the category of functors
from the category G(A) to B with natural transformations as arrows.

Thus an object of S(G, B)(A) is a functor P : G(A) −→ B and an arrow
from P : G(A) −→ B to P (cid:48) : G(A) −→ B is a natural transformation from
P to P (cid:48). It is useful to think of S(G, B)(A) as the category of diagrams
of shape G(A) (or models of G(A)) in B; the arrows between them are
homomorphisms of diagrams, in other words natural transformations.

Embedding or modeling a certain shape (diagram, space, structure, etc.) into a
certain workspace (category, topological space, etc.) in all possible ways is a tool
used all over mathematics. In particular, what we have called the shape functor
is very reminiscent of the singular simplex functors in algebraic topology.

We must say what S(G, B) does to arrows of A op. If f : A −→ A(cid:48) is an
arrow of A , then S(G, B)(f ) : Func(G(A(cid:48)), B) −→ Func(G(A), B) takes
a functor H : G(A(cid:48)) −→ B to H ◦ Gf : G(A) −→ B and it takes a natural
transformation α : H −→ H (cid:48) : G(A(cid:48)) −→ B to the natural transformation
αGf : H ◦ Gf −→ H (cid:48) ◦ Gf : G(A) −→ B whose component at an object X of
A is the component of α at Gf (X). This is the usual action of a functor on
diagrams in a category.

12.4.2 Since S(G, B) : A op −→ Cat is a category-valued functor, we can
use the Grothendieck construction to form the split ﬁbration of A by the
functor S(G, B). This ﬁbration consists of a category denoted A wrG B,
called the wreath product of A by B with given action G, and a functor
Π : A wrG B −→ A .

We now unwind what this implies to give an elementary deﬁnition of the

wreath product.

342

Fibrations

12.4.3 Deﬁnition Given small categories A and B and a functor G : A
−→ Cat, the wreath product A wrG B is a category deﬁned as follows:

WP–1 The objects of A wrG B are pairs (A, P ), where A is an object of A

and P : G(A) −→ B is a functor.

WP–2 An arrow (f, λ) : (A, P ) −→ (A(cid:48), P (cid:48)) of A wrG B has f : A −→ A(cid:48) an
arrow of A and λ : P −→ P (cid:48) ◦ Gf a natural transformation.
WP–3 If (f, λ) : (A, P ) −→ (A(cid:48), P (cid:48)) and (g, µ) : (A(cid:48), P (cid:48)) −→ (A(cid:48)(cid:48), P (cid:48)(cid:48)) are arrows

of A wrG B, as in

G(A)

(cid:45)Gf

G(A(cid:48))

(cid:45)Gg

(cid:64)
P

(cid:64)

(cid:64)

(cid:64)(cid:82)

P (cid:48)
(cid:63)
B

(cid:161)

(cid:161)(cid:170)

G(A(cid:48)(cid:48))
(cid:161)
P (cid:48)(cid:48)

(cid:161)

then

(g, µ) ◦ (f, λ) = (g ◦ f, µ ◦ Gf ◦ λ) : (A, P ) −→ (A(cid:48)(cid:48), P (cid:48)(cid:48))

To see the meaning of WP–3, observe that λ : P −→ P (cid:48) ◦ Gf and µ : P (cid:48)

−→ P (cid:48)(cid:48) ◦ Gg are natural transformations. Then

µ ◦ Gf : P (cid:48) ◦ Gf −→ P (cid:48)(cid:48) ◦ Gg ◦ Gf = P (cid:48)(cid:48) ◦ G(g ◦ f )

is the natural transformation whose component at an object x of G(A) is
the component of µ at Gf (x) (this was described in Section 4.4). Then

µ ◦ Gf ◦ λ : P −→ P (cid:48)(cid:48) ◦ G(g ◦ f )

is the usual composite of natural transformations (see 4.2.11); it is the natu-
ral transformation whose component at an object x of G(A) is the composite
of the components (µ ◦ Gf (x)) ◦ λx.

It follows from WP–3 that there is a projection functor

Π : A wrG B −→ A

taking (A, P ) to A and (f, λ) to f .

12.4.4 Special cases of the wreath product
If the functor G in deﬁ-
nition 12.4.3 is set-valued, then one obtains the discrete wreath product
of A by B with action G. When A and B are both monoids, the discrete
wreath product is also a monoid. (The general case need not be a monoid.)

12.4 Wreath products

343

12.4.5 Deﬁnition For any small category C , the right regular repre-
sentation of C is the functor RC : C −→ Set deﬁned as follows:

RR–1 If C is an object of C , then RC (C) is the set of arrows of C with

codomain C.

RR–2 If f : C −→ C(cid:48) in C and g ∈ RC (C), then RC (f )(g) = f ◦ g.

For small categories A and B, the standard wreath product A wr B
is the wreath product A wrRA B. This is a generalization of what is called
the standard wreath product for groups and monoids. It is the wreath prod-
uct used in [Rhodes and Tilson, 1989]. They also have a two-sided version
of the wreath product.

12.4.6 The action induced by a wreath product Given small cate-
gories A and B and functors G : A −→ Cat and H : B −→ Cat, there is an
induced functor G wr H : A wrG B −→ Cat deﬁned as follows:
WF–1 For an object (A, P ) of A wrG B, (G wr H)(A, P ) is the split opﬁ-

bration induced by H ◦ P : G(A) −→ Cat.

WF–2 If (h, λ) is an arrow of A wrG B with domain (A, P ), and (t, x) is an
object of (G wr H)(A, P ), so that x is an object of G(A) and t is an
object of H(P (x)), then

(G wr H)(h, λ)(t, x) = (Hλx(t), Gh(x))

WF–3 If (u, f ) : (t, x) −→ (t(cid:48), x(cid:48)) is an arrow of (G wr H)(P, A), then

(G wr H)(h, λ)(u, f ) = (H(λx(cid:48))(u), Gh(f ))

WF–1 can be perceived as saying that G wr H is obtained by composing the
shapes given by G (see the discussion in 12.4.1) with H. Indeed, G. M. Kelly,
who invented this concept [1974] called what we call the wreath product the
‘composite’ of the categories. That is in some ways a better name: the word
‘product’ suggests that the two factors are involved in the product in symmetric
ways, which is not the case, as the next subsection describes.

12.4.7 The action G wr H of A wrG B just deﬁned is said to be triangu-
lar because it is a precise generalization of the action of a triangular matrix.
For example, the action
(cid:183)

(cid:184)

(cid:183)

(cid:184)

(cid:184)

(cid:183)

a b
0 c

×

=

x
y

ax + by
cy

can be described this way: the eﬀect on the ﬁrst coordinate depends on both
the ﬁrst and second coordinates, but the eﬀect on the second coordinate
depends only on the second coordinate.

344

Fibrations

The dependency of the action on the coordinates given in WF–2 and
WF–3 is analogous to the dependency for the matrices in the example just
given.

The wreath product can be generalized to many factors, using the follow-
ing theorem, proved in [Kelly, 1974], Section 7. This theorem allows one to
think of the wreath product as generalizing triangular matrices bigger than
2 × 2.

12.4.8 Proposition Let G : A −→ Cat, H : B −→ Cat and K : C −→
Cat be functors. Then there is an isomorphism of categories I making this
diagram commute.

A wrG(B wrH C )

(cid:45)I

(A wrG B) wrG wr H C

(cid:64)
G wr(H wr K)

(cid:64)

(cid:161)
(G wr H) wr K

(cid:161)

(cid:64)

(cid:161)

(cid:64)(cid:64)(cid:82)

(cid:161)(cid:161)(cid:170)

Cat

Note that the standard wreath product is not associative.

12.4.9 Applications of the wreath product It is natural to wish to
simulate complicated state transition systems using systems built up in some
way from a small stock of simpler ones. This requires a precise notion of
simulation. This is deﬁned in various ways in the literature. In some cases
one says a functor F : C −→ D is a simulation of D (the word ‘cover’ is often
used) if it has certain special properties. Other authors have the functor
going the other way.

The Krohn–Rhodes Theorem for monoids says that every ﬁnite monoid
action is simulated by an iterated wreath product of ﬁnite simple groups and
certain very small monoids. The original Krohn–Rhodes Theorem was stated
for semigroups. Discussions are in [Wells, 1976] and [Eilenberg, 1976]; the
latter uses a diﬀerent deﬁnition of cover. Wells [1980] proved a generalization
of a weak form of the Krohn–Rhodes Theorem for ﬁnite categories and set-
valued functors (which generalize the concept of action by a monoid, as
discussed in Section 3.2). Wells [1988a, 1988b] describes how to use some of
these decomposition techniques for category-valued functors.

Rhodes and Tilson use the idea of ‘division’ of categories, which is related
to the notion of cover, as the basic idea of an extensive study of varieties of
semigroups and complexity. See See [Rhodes and Tilson, 1989, Rhodes and
Weil, 1989].

Nico [1983] deﬁnes a category induced by any functor called the ‘kernel
category’ of the functor and proves a theorem which embeds the domain

12.4 Wreath products

345

of the functor into the standard wreath product of the codomain and the
kernel. This generalizes an old theorem of Kaloujnine and Krasner. It follows
that every functor factors as a full and faithful functor which is injective on
objects, followed by a ﬁbration. Street and Walters [1973] have a related
theorem.

In the case of groups, the kernel category of a homomorphism is a cate-
gory equivalent, but not isomorphic, to the actual kernel of the homomorph-
ism. In the case that C and D are monoids, the kernel category (which is
not a monoid in general) is called the derived category of F . Rhodes and
Tilson [1989] have a tighter deﬁnition obtained by imposing a congruence on
the kernel. A theorem analogous to Nico’s theorem is true for the tighter def-
inition, as well. It is stated for semigroups and relations, not merely monoids
and homomorphisms, so it is neither more nor less general than Nico’s the-
orem. In the semigroup case, the ‘category’ is replaced by a ‘semigroupoid’,
which is like a category but does not have to have identity arrows.

12.4.10 Exercises

1. Show that the discrete wreath product of two monoids is a monoid.

2. Show that the wreath product of two groups (monoids in which every
element is invertible) regarded as categories is a category in which every
arrow is an isomorphism.

13
Adjoints

Adjoints are about the most important idea in category theory, except per-
haps for the closely related notion of representable functors. Many construc-
tions made earlier in this book are examples of adjoints, as we will describe.
Moreover, toposes are most conveniently described in terms of adjoints.

This chapter develops enough of the basic theory of adjoints to read
the last two chapters of the book. Section 13.1 revisits the concept of free
monoids, describing them in a way which suggests the general deﬁnition of
adjoint. Adjoints are described and some basic properties developed in Sec-
tions 13.2 and 13.3. Section 13.4 describes locally cartesian closed categories,
which are best described using adjoints.

More detail concerning adjoints can be found in [Barr and Wells, 1985]
and [Mac Lane, 1971]. Diers [1980a], [1980b] describes a generalization which
includes the initial families of FD sketches (see Section 8.3). Hagino [1987a],
[1987b] has a general approach to type constructors for functional program-
ming languages based on adjoints (see also [Chen and Cockett, 1989]).

Much of this chapter can be read after completing Section 4.5. Some
of the material in the chapter requires the concepts of limit and colimit
from Chapters 5 and 9. One major example of an adjoint, cartesian closed
categories, requires Sections 5.1 and 6.1. The concept of adjoint is used
heavily in the rest of the book, but Section 13.4 is not needed later.

13.1 Free monoids

In 3.1.14, we gave the universal property of the free monoid. We now state
it more carefully than we did there, paying closer attention to the categories
involved. Note that when we speak of a subset of a monoid, we are mix-
ing two things. A monoid is not just a set and most of its subsets are not
submonoids. To describe a monoid, you must give three data: the set of ele-
ments, the operation and the identity element. From this point of view the
phrase ‘subset of a monoid’ does not make sense. It is actually a subset of the
underlying set of the monoid. Insistence on this is not pointless pedantry; it
is the key to understanding the situation.

Let Mon denote the category of monoids and let U : Mon −→ Set denote
the underlying set functor. We deﬁne a monoid M to be a triple (U M, ·, 1),

347

348

Adjoints

where U M is a set called the underlying set of M , · is a binary operation on
U M and 1 ∈ U M is the identity element for that operation. A homomorph-
ism from a monoid M to a monoid N is a function f : U M −→ U N which
preserves the operation and the identity element. The underlying functor is
deﬁned on homomorphisms by U f = f .

13.1.1 Characterization of the free monoid Given a set X, the free
monoid F (X) = (X ∗, ·, (cid:104)(cid:105)) is characterized by the property given in the fol-
lowing proposition; the property is called the universal mapping property
of the free monoid. In the proposition, ηX : X −→ X ∗ = U F (X) takes x ∈ X
to the string (cid:104)x(cid:105) of length 1. We systematically distinguish the free monoid
F (X) from its underlying set, the Kleene closure X ∗ = U (F (X)).

13.1.2 Proposition Let X be a set. For any monoid M and any function
u : X −→ U (M ), there is a unique monoid homomorphism g : F (X) −→ M
such that u = U g ◦ ηX.

Proof. Deﬁne g((cid:104)(cid:105)) to be the identity element of M , g((cid:104)x(cid:105)) = u(x) for x ∈ X,
and g((cid:104)x1 · · · xn(cid:105)) to be the product u(x1) · · · · · u(xn) in M . That makes
g a monoid homomorphism and u = U g ◦ ηX; the details are left as an
exercise.

Just as the theory of a sketch is the universal model of that sketch, the
free monoid generated by a set is universal for functions from that set into
the set underlying a monoid.

This proposition says that the arrow ηX is a universal element for the
functor Hom(X, U −) that takes a monoid M to Hom(X, U (M )) and a mon-
oid homomorphism f : M −→ N to Hom(X, U (f )) : Hom(X, U (M )) −→ Hom(X, U (N )).
It follows that the universal mapping property characterizes the free monoid
up to a unique isomorphism. Precisely, let X be a set and γ : X −→ U (E) a
function to the underlying set of some monoid E with the property that if
u : X −→ U (M ), where M is any monoid, there is a unique monoid homo-
morphism f : E −→ M such that u = U (f ) ◦ γ. We now show that there is a
unique isomorphism φ : E −→ F (X) for which

X

(cid:161)

(cid:64)

(cid:64)

(cid:45)

ηX
(cid:64)

(cid:64)(cid:82)
U (F (X))

U (φ)

(cid:161)

γ
(cid:161)

(cid:161)(cid:170)

U (E)

commutes. As we have noted above, ηX is a universal element of the functor
Hom(X, U (−)). The assumption on γ says that it is also a universal element

13.1 Free monoids

349

for the same functor. Now Corollary 4.5.13 says there is a unique isomorph-
ism φ : E −→ F (X) for which Hom(X, U (φ))(γ) = ηX. The result follows
because Hom(X, U (φ))(γ) = U (φ) ◦ γ by deﬁnition.

13.1.3 The free monoid functor Each set X generates a free monoid
F (X). In 3.1.12, we extended this to a functor F : Set −→ Mon. In this
section, we will prove this (as part of the proof of Proposition 13.1.4 be-
low) using only the universal mapping property of free monoids; thus the
argument will work in complete generality.

Let ηY denote the arrow from Y into Y ∗ = U F Y described in 13.1.1
and let f : X −→ Y be a function. Then ηY ◦ f : X −→ Y ∗ is a function
from X into the set underlying a monoid. The universal property of F (X)
gives a unique monoid homomorphism F (f ) : F (X) −→ F (Y ) such that if
f ∗ = U F (f ), then

X

Y(cid:45)f

ηX

ηY

(cid:63)
X ∗

(cid:63)
Y ∗(cid:45)

f ∗

(13.1)

commutes.

13.1.4 Proposition F : Set −→ Mon is a functor and, for any set X,
ηX is the component at X of a natural transformation η : idSet −→ U ◦ F .

Proof. Once F is shown to be a functor, that η is a natural transformation
will follow from Diagram (13.1).

First note that if id : X −→ X is the identity, then F (id) is the unique

arrow h : F (X) −→ F (X) such that

X

X(cid:45)id

ηX

ηX

(cid:63)
X ∗

(cid:63)
X ∗(cid:45)

U h
commutes. But if we replace h in the diagram above by idF X , the diagram
still commutes. The uniqueness property of the free monoid implies that
h = idF X .

350

Adjoints

Similarly, if g : Y −→ Z is a function, the commutativity of both squares

in

X

Y(cid:45)f

Y

Z(cid:45)g

ηX

ηY

ηY

ηZ

(cid:63)
X ∗

(cid:63)
Y ∗(cid:45)

f ∗

(cid:63)
Y ∗

(cid:63)
Z∗(cid:45)

g∗

implies that

X

Z(cid:45)g ◦ f

ηX

ηZ

(cid:63)
X ∗

(cid:63)
Z∗(cid:45)

g∗ ◦ f ∗
commutes. But g∗ ◦ f ∗ = U F (g) ◦ U F (f ) = U (F (g) ◦ F (f )) since U is a
functor. This means that the arrow F (g) ◦ F (f ) satisﬁes the same equation
that characterizes F (g ◦ f ) uniquely and hence that they are equal. This
shows that F is a functor and that η is a natural transformation.

Another example of functors F and U satisfying this is the free category
given by a graph as described in 2.6.16. This very same proof shows that the
free category construction is really the object part of a functor.

13.1.5 Exercise

1. Show that the function g deﬁned in the proof of Proposition 13.1.2 is a
monoid homomorphism from F (X) to M .

13.2 Adjoints

The relationship between the free monoid functor and the underlying set
functor is an example of a very general situation, an adjunction, deﬁned
below.

In this section, we have several notational shortcuts to prevent clutter of
parentheses and composition circles. This notation is quite standard in the
literature on adjoints. For example, an expression U F U A is shorthand for
(U ◦ F ◦ U )(A), which is the same as U (F (U (A))).

13.2.1 Deﬁnition Let A and B be categories. If F : A −→ B and U : B
−→ A are functors, we say that F is left adjoint to U and U is right
adjoint to F provided there is a natural transformation η : id −→ U F such

that for any objects A of A and B of B and any arrow f : A −→ U B, there
is a unique arrow g : F A −→ B such that

13.2 Adjoints

351

A

U F A(cid:45)ηA
(cid:64)
f

(cid:64)

(cid:64)(cid:82)

U g
(cid:63)
U B

(13.2)

commutes.

This deﬁnition asserts that there is a functional way to convert any arrow
f : A −→ U B to an arrow g : F A −→ B in such a way that g solves the
equation f = U (?) ◦ ηA, and that the solution is unique.

The property of η given in the last sentence of Deﬁnition 13.2.1 is called
its universal mapping property. The existence of the unique arrow g : F A
−→ B such that f = U g ◦ ηA is the map-lifting property of Section 3.1.14.
Just as in the discussion after Proposition 13.1.2, for each object A, the
arrow ηA is a universal element for the functor Hom(A, U (−)).

It is customary to write F

U to denote the situation described in the
deﬁnition. The data (F, U, η) constitute an adjunction. The transformation
η is called the unit of the adjunction.

In some texts the adjunction is written as a rule of inference, like this:

A −→ U B
F A −→ B

(13.3)

The deﬁnition appears to be asymmetric in F and U . This is remedied in
the next proposition, whose proof is deferred to the next section, after the
proof of Theorem 13.3.2.

13.2.2 Proposition Suppose F : A −→ B and U : B −→ A are functors
such that F
U . Then there is a natural transformation (cid:178) : F U −→ idB
such that for any g : F A −→ B, there is a unique arrow f : A −→ U B such
that

F U B

F f
(cid:161)

F A

(cid:161)(cid:181)

(cid:161)

(cid:178)B
(cid:63)
B(cid:45)
g

(13.4)

The transformation (cid:178) is called the counit of the adjunction.
It is an immediate consequence of categorical duality that this proposition
is reversible and the adjunction is equivalent to the existence of either natural
transformation η or (cid:178) with its appropriate universal mapping property.

352

Adjoints

13.2.3 Examples of adjoints We have of course the example of free
monoids that introduced this chapter. In general, let C be a category of sets
with structure and functions which preserve the structure, and let U : C
−→ Set be the underlying set functor. If U has a left adjoint F and S is a
set, then F (S) is the free structure on S. This description ﬁts structures
you may know about, such as free groups, free Abelian groups and free rings.
We now give three related examples that illustrate how widespread ad-

joints are.

13.2.4 Example Let C be a category. Consider the category C ×C which
has as objects pairs of objects (A, B) of C and in which an arrow (A, B)
−→ (A(cid:48), B(cid:48)) is a pair (f, g) of arrows f : A −→ A(cid:48) and g : B −→ B(cid:48). There is a
functor ∆ : C −→ C × C given by ∆(A) = (A, A) and ∆(f ) = (f, f ). Let us
see what a right adjoint to this functor is.

Assuming there is a right adjoint Π to ∆, there should be an arrow we

call

(cid:104)p1, p2(cid:105) : ∆Π(A, B) = (Π(A, B), Π(A, B)) −→ (A, B)

(this is the counit of the adjunction) with the following universal property:

PP For any object C of C and any arrow (cid:104)q1, q2(cid:105) : ∆C = (C, C) −→ (A, B)
there is a unique arrow q : C −→ Π(A, B) such that

(cid:45)(cid:104)q, q(cid:105)

(Π(A, B), Π(A, B))

(C, C)
(cid:64)

(cid:64)

(cid:64)
(cid:104)q1, q2(cid:105)

(cid:64)

(cid:64)

(cid:64)

(cid:104)p1, p2(cid:105)

(cid:64)

(cid:63)
(cid:64)(cid:82)
(A, B)

commutes.

A diagram in a product category commutes if and only if each compo-
nent does. Breaking the triangle into components the adjunction asserts the
existence of a unique map q : C −→ Π(A, B) such that each of the triangles

(cid:45)q

C

Π(A, B)

C

(cid:45)q

Π(A, B)

(cid:64)
q1

(cid:64)

(cid:64)

(cid:64)(cid:82)

p1

(cid:63)
A

(cid:64)
q2

(cid:64)

(cid:64)

(cid:64)(cid:82)

p2

(cid:63)
B

13.2 Adjoints

353

commutes. If you write A × B instead of Π(A, B) you will recover the cate-
gorical deﬁnition of the product. Thus a right adjoint to ∆ is just a functor
Π : C × C −→ C that chooses a product for each pair of objects of C . Such
a functor Π is called a binary product functor.

13.2.5 Example Now let us suppose we are given a binary product func-
tor Π. We can ﬁx an object A of C and consider the functor denoted −×A : C
−→ C whose value at an object B is the object B × A and at an arrow f : B
−→ C is the arrow f × idA : B × A −→ C × A (see 5.2.17).

A right adjoint to the functor − × A, if one exists, can be described as
follows. Denote the value at C of this adjoint by RA(C). Then there is an
arrow e : RA(C) × A −→ C with the universal property that for any arrow
f : B × A −→ C, there is a unique arrow we may call λf : B −→ RA(C)
such that e ◦ (λf × A) = f . But this is precisely the universal property that
describes the exponential [A −→ C] (see 6.1.3). The counit e is the arrow eval
deﬁned there. The essential uniqueness of adjoints (see 13.3.4 below) implies
that this adjunction property determines the exponential, if it exists, up to
isomorphism.

Thus the two main deﬁning properties deﬁning cartesian closed cate-
gories, namely the existence of binary products and the existence of expo-
nentials, can be (and commonly are) described in terms of adjoints.

13.2.6 Example We can describe the functor − × A of 13.2.5 in a slightly
diﬀerent way. For a category C and object A of C we described the slice
category C /A in 2.6.10 and functor UA : C /A −→ C in 3.1.11. If UA has a
right adjoint PA : C −→ C /A, then PA must associate to each object C of
C an object φAC = PA(C) : TAC −→ A of C /A and an arrow (the counit)
(cid:178)AC : TAC −→ C. This object and arrow must have the universal mapping
property that for any other object f : B −→ A of C /A, and any arrow g : B
−→ C there is a unique arrow h : B −→ TAC such that
h

h

B

B

(cid:64)
(cid:64)
f

TAC(cid:45)
(cid:161)
φAC

(cid:161)

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

A

TAC(cid:45)
(cid:161)
(cid:178)AC

(cid:161)

(cid:64)
g
(cid:64)

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

C

commute. The left triangle must commute in order to have an arrow in
C /A and the right hand triangle must commute for its universal mapping
property. It is evident from this description that TAC is C × A and (cid:178)AC
and φAC are the ﬁrst and second projections. Thus PA(C) is the object
p2 : C × A −→ A of C /A.

We return to this topic in Exercise 5 of Section 13.3 and in Section 13.4.

354

Adjoints

13.2.7 Adjoints to the inverse image functor Here is another exam-
ple of an adjoint. If S is a set, the set of subsets of S is a poset ordered
by inclusion. This becomes a category in the usual way. That is, if S0 and
S1 are subsets of S, then there is exactly one arrow S0 −→ S1 if and only
if S0 ⊆ S1. You should not view this arrow as representing a function, but
just a formal arrow that represents the inclusion. We will call this category
Sub(S).

If f : S −→ T is a function, then with any subset T0 ⊆ T , we get a subset,

denoted

f −1(T0) = {s ∈ S | f (s) ∈ T0}
which is called the inverse image under f of T0. If T0 ⊆ T1, then f −1(T0) ⊆
f −1(T1). This means that f −1 is a functor from Sub(T ) −→ Sub(S). This
functor turns out to have both left and right adjoints.

The left adjoint is a familiar one (to mathematicians at least), the so-

called direct image. For S0 ⊆ S, let

f∗(S0) = {f (s) | s ∈ S0}
Then f∗(S0) ⊆ T0 if and only if S0 ⊆ f −1(T0) (proof left as an exercise) which
is just the statement that the direct image is left adjoint to the inverse image.
The right adjoint of the inverse image is usually denoted f! and is deﬁned
by saying that t ∈ f!(S0) if and only if f −1({t}) ⊆ S0. Another way of saying
this is that every element of the inverse image of t is in S0, while t ∈ f∗(S)
if and only if some element of the inverse image of t is in S0.

We discussed these constructions in 3.1.18 and 3.1.19 for Set.

13.2.8 Adjoints in posets Example 13.2.7 is a special case of an adjunc-
tion between ordered or even preordered sets. Let P and Q be preordered
sets, that is categories in which there is at most one arrow between any pair
of objects. We will use ≤ for the preorder relation, and the reader may ﬁnd it
more natural to think of this relation as a partial ordering (antisymmetric as
well as reﬂexive and transitive). If f : P −→ Q and u : Q −→ P are functors,
that is, order preserving functions, then f
u means, when translated into
poset language (where uniqueness is not a consideration, since there is at
most one arrow between any two objects), that

and

x ≤ (u ◦ f )(x) for all x ∈ X

x ≤ u(y) implies f (x) ≤ y

(13.5)

(13.6)

for all x ∈ X and y ∈ Y . We claim that these two conditions together are
equivalent to the condition

f (x) ≤ y if and only if x ≤ u(y)

(13.7)

13.2 Adjoints

355

In fact, assuming (13.5) and (13.6), then if f (x) ≤ y, we have

x ≤ (u ◦ f )(x) ≤ u(y)

Condition (13.7) follows from this and (13.6). Conversely if (13.7) holds,
then (13.6) is immediate and f (x) ≤ f (x) implies that x ≤ (u ◦ f )(x). This is
a special case of the Hom set adjunction of the next section (Theorem 13.3.2).
A very common situation involves a pair of contravariant, that is order
reversing, functors. In that case, we can dualize either P or Q. Suppose we do
the former. Then we have a pair of functors f : P op −→ Q and u : Q −→ P op.
u, then, translating this condition back to P , we see that f (x) ≤ y if
If f
and only if u(y) ≤ x. Such a pair of contravariant functors is often called a
Galois connection between P and Q, named after the ﬁrst one produced
by Galois.

If you know Galois theory of ﬁelds, then you know that E is a Galois extension
of F , then there is a one-one order reversing correspondence between subﬁelds
of E that include F and subgroups of the Galois group of E over F . This
particular Galois correspondence is an equivalence and some people prefer to
restrict the use of the term ‘Galois connection’ to the case of equivalence, while
others use it as we have and call the other a Galois equivalence.

13.2.9 Exercises

1. Show that if f : S −→ T is a function between sets, then for S0 ⊆ S and
T0 ⊆ T , S0 ⊆ f −1(T0) if and only if f∗(S0) ⊆ T0.

2. Show that a left adjoint to the functor ∆ of 13.2.3, if it exists, takes the
pair of objects A, B to the sum A + B.

3. Find the unit of the adjunction ∆ Π described in Section 13.2.3.

4. Let R and Z denote the ordered sets of real numbers and integers, respec-
tively, considered as categories. Show that the inclusion Z ⊆ R has both a
left and a right adjoint and identify them.
5.† Show that the construction of free models of a linear sketch in 4.7.17
gives an example of an adjunction analogous to the free monoid functor.

6. Show that the construction of the path category of a graph in 2.6.16 is
left adjoint to the underlying functor from categories to graphs.

7. Find left and right adjoints to the underlying set of objects functor from
Cat to Set (see Example 3.1.10).

8. Show that the underlying arrow set functor of Example 3.1.10 from Cat
to Set has a left adjoint but not a right adjoint.

356

Adjoints

9. Show that for any set A with other than one element, the functor − × A :
Set −→ Set deﬁned in 13.2.5 does not have a left adjoint in Set. (Hint: 1 × A
is isomorphic to A.)

10. In Section 13.2.5, a right adjoint to the functor − × A is described. The
counit of the adjunction is the transformation e deﬁned there. Describe the
unit in general and in Set.

13.3 Further topics on adjoints

13.3.1 Hom set adjointness There is an alternative formulation of ad-
jointness which is often found in the categorical literature.

13.3.2 Theorem If A and B are categories and U : B −→ A and F : A
U if and only if Hom(F −, −) and Hom(−, U −)
−→ B are functors, then F
are naturally isomorphic as functors A op × B −→ Set.

Proof. Let F
U , and let A and B be objects of A and B respectively. De-
ﬁne βA,B : Hom(F A, B) −→ Hom(A, U B) by βA,B(g) = U g ◦ ηA, and γA,B :
Hom(A, U B) −→ Hom(F A, B) by requiring that γA,B(f ) be the unique arrow
g such that f = U g ◦ ηA given by Deﬁnition 13.2.1. Then γA,B(βA,B(g)) = g
by the uniqueness requirement of Deﬁnition 13.2.1, and βA,B(γA,B(f )) = f
by deﬁnition of βA,B and γA,B. Thus βA,B is an isomorphism with inverse
γA,B. The naturality is left as an exercise (Exercise 3).

To go in the other direction, suppose we have the natural isomorph-
ism. Then let A be an arbitrary object of A and B = F A. We then get
Hom(F A, F A) ∼= Hom(A, U F A). Let ηA ∈ Hom(A, U F A) be the arrow that
corresponds under the isomorphism to the identity arrow of F A. Now for an
arrow f : A −→ U B, that is f ∈ Hom(A, U B), let g ∈ Hom(F A, B) be the
arrow that corresponds under the isomorphism. Naturality of the isomorph-
ism implies that we have a commutative diagram

Hom(F A, F A)

∼=

(cid:45)

Hom(A, U F A)

Hom(F A, g)

Hom(A, U g)

(cid:63)

Hom(F A, B)

(cid:45)

(cid:63)
Hom(A, U B)

∼=

If we follow the identity arrow of F A around the clockwise direction, we get
ﬁrst the arrow ηA by deﬁnition, and then Hom(A, U g)(ηA) = U g ◦ ηA. In the
other direction, we get Hom(F A, g)(id) = g ◦ id = g and that corresponds
under the isomorphism to f . Thus we conclude that f = U g ◦ ηA. As for the

13.3 Further topics on adjoints

357

uniqueness, if f = U h ◦ ηA, then both g and h correspond to f under the
isomorphism, so g = h.

13.3.3 Proof of Proposition 13.2.2 The hypotheses of the above the-
orem are symmetric in F and U and therefore the conclusion must be too.
Thus categorical duality implies the existence of (cid:178) and the requisite universal
mapping property.

13.3.4 Uniqueness of adjoints
If U : B −→ A is a functor, then a left
adjoint to U , if one exists, is unique up to natural isomorphism. The reason
is that if both F and F (cid:48) are left adjoint to U , then for any object A of
A , the Hom functors HomB(F A, −) and HomB(F (cid:48)A, −) are each naturally
isomorphic to HomA (A, U −) and hence to each other. It follows from the
Yoneda embedding, Theorem 4.5.3, that F A ∼= F (cid:48)A. The naturality of the
latter isomorphism follows from the next theorem.

13.3.5 Theorem Let A and B be categories and U : B −→ A be a func-
tor. Suppose for each object A of A there is an object F A of B such that
HomB(F A, −) is naturally equivalent to HomA (A, U −) as a functor from
B to Set. Then the deﬁnition of F on objects can be extended to arrows in
such a way that F becomes a functor and is left adjoint to U .

This theorem is called the Pointwise Adjointness Theorem. Its proof
generalizes the argument of 13.1.3 but we omit the details. They can be
found in [Barr and Wells, 1985], Section 1.9, Theorem 1, page 52. There is a
detailed, general discussion of many equivalent deﬁnitions of adjunction in
[Mac Lane, 1971], Chapter IV.

One application of this theorem is in showing that the deﬁnition of carte-
sian closed categories given in Chapter 6 is equivalent to the assumptions
that the functors ∆ of 13.2.3 and − × A of 13.2.5 have adjoints. In each case,
the deﬁnition given in Chapter 6 can be input to the Pointwise Adjointness
Theorem and the output is the adjoint described in the previous section.

This theorem has a simple formulation in terms of the universal elements

of Section 4.5, as follows.

13.3.6 Proposition A functor U : B −→ A has a left adjoint if and only
if for each object A of A , the functor Hom(A, U −) : B −→ Set has a uni-
versal element.

If b : A −→ U B is the universal element, then F A = B and b : A −→ U B =
U F A is the component at A of the natural transformation η that appears
in 13.2.1.

As an example of how this proposition can be used, one can use it to
deduce from Proposition 13.1.2 that X (cid:55)→ F (X) is the object map of a left

358

Adjoints

adjoint to the underlying functor U : Mon −→ Set. Of course, we proved
this directly in 13.1.3.

13.3.7 Theorem Let F : A −→ B be left adjoint to U : B −→ A . Then
U preserves limits and F preserves colimits.

Proof. We sketch the proof that U preserves limits; the details are easy, but
the notation is slightly unpleasant. Recall the deﬁnition of the cone functor
cone(−, D) : C op −→ Set from 9.2.6. Then we have, for a diagram D : I
−→ B with limit given by a cone V −→ D, the following equivalences of
contravariant functors:

cone(−, U D) ∼= cone(F −, D) ∼= Hom(F −, V ) ∼= Hom(−, U V )

which shows that U V is a limit of U D. The ﬁrst isomorphism in that equa-
tion should be veriﬁed, since we extended the isomorphism of Theorem 13.3.2
from the hom functor to the cone functor, but that veriﬁcation is straightfor-
ward. The second isomorphism follows from the fact that the cone V −→ D
is a universal element of cone(−, D), so that cone(−, D) ∼= Hom(−, V ). The
third isomorphism follows from Theorem 13.3.2.

The interesting question is the extent to which the converse is true. The
basic fact is that the converse is false. First, the category B may not have
enough limits for the condition to be meaningful. The really interesting case
is the one in which every (small) diagram in B has a limit. Even in that
case, there is still what can basically be described as a size problem. To go
into this in more detail is beyond the scope of this book. The best result is
Freyd’s Adjoint Functor Theorem. See [Barr and Wells, 1985], Section 1.9,
Theorem 3, page 54 or [Mac Lane, 1971], Section V.6. Another reference for
the Adjoint Functor Theorem (with a diﬀerent point of view) is [Freyd and
Scedrov, 1990], pages 144–146.

13.3.8 Exercises

1. Suppose that we have categories A and B and functors T : A −→ B and
L, R : B −→ A such that L
RT as endofunctors
on A and T L

T
T R as endofunctors on B.

R. Show that LT

2. a. Suppose that X is a set of real numbers, considered as an ordered set,
considered as a category. Show that a limit of the inclusion of X ⊆ R, if any,
is the inﬁmum of X, if that exists, and similarly that the colimit of that
inclusion is the supremum of X.

b. Referring to Exercise 4 of the previous section, show that the ceiling
function preserves supremum, but not necessarily inﬁmum, and the ﬂoor
function preserves inﬁmum, but not necessarily supremum.

13.3 Further topics on adjoints

359

3. Show that βA,B, as deﬁned in the proof of Theorem 13.3.2, is a natural
transformation from HomB(F −, −) to HomA (−, U −), both functors from
A op × B to Set.

4. For any functor G : C −→ D, let Gop : C op −→ D op be the functor which
is the same as G on objects and arrows. Show that, for any functors F and
U , if F is left adjoint to U then F op is right adjoint to U op.
5.† This is a series of exercises designed to show that if the category C has
ﬁnite limits, then the existence of a right adjoint RA to the functor PA
of 13.2.6 is equivalent to the existence of an exponential object [A −→ −]
in C . This is a functor that satisﬁes the universal mapping property that
Hom(A × B, C) ∼= Hom(B, [A −→ C]) for all objects B and C of C . (See
Section 6.1.)

a. Let A be an object of C , PA : C −→ C /A the functor deﬁned in 13.2.6
which takes an object C to p2 : C × A −→ A, and LA : C /A −→ C the un-
derlying object functor which takes f : B −→ A to B. Show that LA is left
adjoint to PA.

b. Show that if PA : C −→ C /A has a right adjoint RA, then the functor

A × − : C −→ C does as well.

c. Suppose that C is cartesian closed. Show that for each object of the
form PA(C) in C /A, the object Φ(PA(C)) = [A −→ C] in C has the basic
adjunction property:

Hom(B, Φ(PA(C))) ∼= HomA(PA(B), PA(C))

d. Show that every arrow f : PA(C) −→ PA(D) in C /A induces an arrow

Φ(f ) : Φ(C) −→ Φ(D) such that

Hom(B, Φ(C))

Hom(B, Φ(f ))

(cid:63)

Hom(B, Φ(D))

∼=
(cid:45)

(cid:45)
∼=

Hom(PA(B), PA(C))

Hom(B, f )

(cid:63)
Hom(PA(B), PA(D))

commutes. (Hint: Use the Yoneda Lemma.)

e. Show that if f : C −→ A is an arbitrary object of C /A, then there is

an equalizer diagram

d

−−→ PA(C)

f

d 0
−−−→−−−→
d 1

PALAPA(C)

360

Adjoints

(Hint: Use elements.)

f. Show that if we let, for an object f : C −→ A of C /A,

Φ(f ) −→ Φ(PA(C))

Φ(d 0)
−−−−−→−−−−−→
Φ(d 1)

Φ(PA(PA(C)))

be an equalizer, then for any object B of C ,

Hom(B, Φ(f )) ∼= HomA(PA(B), f )

g. Show that PA has a right adjoint.

13.4 Locally cartesian closed categories

A locally cartesian closed category is a special type of cartesian closed cat-
egory which has properties desirable for modeling polymorphism. Its deﬁni-
tion, which we give here, makes intrinsic use of adjunctions.

13.4.1 The pullback functor Let C be a category with pullbacks. Sup-
pose f : A −→ B is an arrow. Then for any object u : X −→ A of the slice
category C /A, there is an object f ◦ u : C /A −→ C /B that is the object
part of a functor we denote Σf : C /A −→ C /B. If v : Y −→ A is another
object and g : X −→ Y an arrow, that is a map in C such that v ◦ g = u,
then f ◦ v ◦ g = f ◦ u so that g is also an arrow in C /B. This deﬁnes Σf on
arrows and it is immediate that it is a functor.

We now show, using Theorem 13.3.5, that Σf has a right adjoint f ∗ : C /B

−→ C /A. If x : X −→ B is an object of C /B, f ∗(x) = p1 : P −→ A, where

P

X(cid:45)p2

p1

(cid:63)
A

f

x

(cid:63)
B(cid:45)

(13.8)

is a pullback diagram.

To see what f ∗ does on arrows, suppose f ∗(x : X −→ B) = p1 : P −→ A as
1 : P (cid:48) −→ A, the latter given by the pullback

above, and f ∗(x(cid:48) : X (cid:48) −→ B) = p(cid:48)

X (cid:48)(cid:45)p(cid:48)

2

P (cid:48)

p(cid:48)
1

(cid:63)
A

f

x(cid:48)
(cid:63)
B(cid:45)

(13.9)

13.4 Locally cartesian closed categories

361

Suppose t : x −→ x(cid:48) is an arrow of C /B. Then

x(cid:48) ◦ t ◦ p2 = x ◦ p2 = f ◦ p1

because t is an arrow in C /B and Diagram (13.8) commutes. Thus P with
t ◦ p2 and p1 is a commutative cone over the pullback diagram (13.9), so
induces an arrow s : P −→ P (cid:48) such that p(cid:48)
2 ◦ s = t ◦ p2. The
ﬁrst equation says that s is an arrow from p1 to p(cid:48)
1 in C /A, and so f ∗(t) = s.
This shows what f ∗ must be on arrows. Then Theorem 13.3.5 puts it all
together into a functor.

1 ◦ s = p1 and p(cid:48)

13.4.2 Proposition Let C be a category with pullbacks and f : A −→ B
an arrow of C . Then Σf as deﬁned above is left adjoint to f ∗.

The proof is omitted. The construction in 13.2.6 is a special case of this
construction, at least in the case where C has a terminal object. To see this,
let f be the unique arrow from A to 1 and note that the pullback becomes
a product and C /1 is isomorphic to C .

The pullback functor need not have a right adjoint, in fact that is a
rather rare occurrence. The following theorem characterizes those categories
in which it does have a right adjoint.

13.4.3 Theorem The following are equivalent for any category C .

(a) C has pullbacks and for each arrow f : A −→ B, the pullback functor

f ∗ : C /B −→ C /A has a right adjoint.

(b) For every object A of C , the slice category C /A is cartesian closed.

The right adjoint to the pullback functor f ∗ is denoted Πf (∀f in some

texts).

We sketch the proof. The proof hinges on the following proposition, whose

easy proof we omit.

13.4.4 Proposition For any arrows u : X −→ A and v : Y −→ A in any
category, the arrow from P to A given by a pullback diagram

P

X(cid:45)p2

p1

u

(cid:63)
Y

(cid:63)
A(cid:45)

v

(13.10)

is the product of u and v in the slice category C /A.

362

Adjoints

Now we give the proof of Theorem 13.4.3. Suppose the conditions in (a)
hold. Let us consider arrows u : X −→ A, v : Y −→ A and w : Z −→ A of C /A.
It is clear from Proposition 13.4.4 that, in C /A,

u × v = u ◦ p2 = Σu(u∗(v))

By hom set adjointness (Theorem 13.3.2), we then have

HomC /A(u × v, w) = HomC /A(Σu(u∗(v)), w)
∼= HomC /X (u∗(v), u∗(w))
∼= HomC /A(v, Πu(u∗(w)))

so that deﬁning [u −→ w] to be Πu(u∗(w)) gives the cartesian closed structure
on C /A.

For the converse, let C denote a category with the property that every
slice is a cartesian closed category. Since any slice of a slice of the form
(C /A)/f , for f : B −→ A is isomorphic to the slice C /B (Exercise 12 of
Section 3.3), we know that every slice of C also has the property that every
slice is a cartesian closed category.

We now show that every slice has ﬁnite limits. Since every slice has
products, C has pullbacks by Proposition 13.4.4. It follows from the remark
in the preceding paragraph that every slice has pullbacks as well. Since also
every slice has a terminal object (id : A −→ A is automatically terminal in
C /A), it follows from Proposition 9.3.7 of Section 9.3 that every slice has
ﬁnite limits.

It now follows from Exercise 5 of Section 13.3 that for any f : A −→ B in

C , the induced f ∗ : C /B −→ C /A has a right adjoint.

13.4.5 Deﬁnition A category C which satisﬁes (a) (or equivalently (b))
of Theorem 13.4.3 is a locally cartesian closed category.

If a category C has a terminal object 1, C is isomorphic as a category to

C /1. We then have the following proposition.

13.4.6 Proposition A locally cartesian category which has a terminal object
is cartesian closed.

Applications are discussed in [Seely, 1984] and [Seely, 1987a].

14
Algebras for endofunctors

In this chapter, we describe some constructions based on an endofunctor
of a category C , which is a functor from C to C .

We begin in Section 14.1 to study the concept of ﬁxed point and least
ﬁxed point of an endofunctor. A natural structure to be a ﬁxed point is
what is called an algebra for the endofunctor, which is deﬁned there. These
algebras are suitable for developing a concept of list object in a category (Sec-
tion 14.2) and a categorical version of state transition machines (14.2.10).

A triple is a structure which abstracts the idea of adjunction; part of
the structure is an endofunctor. Triples have turned out to be an important
technical tool in category theory. Section 14.3 deﬁnes triples and gives some
of their basic properties. In Section 14.4 we develop the idea of an algebra
for a triple; it is an algebra for the endofunctor part of the triple with certain
properties. The last section describes a technique of Smyth and Plotkin to
construct Scott domains, which provide models of computations in carte-
sian closed categories. These models allow modeling recursion by ﬁxed point
techniques, and the models are themselves constructed as ﬁxed points. This
last section requires only Section 14.1 to be read.

The material in this chapter is not needed for the rest of the book, except

for some examples.

14.1 Fixed points for a functor

14.1.1 What are ﬁxed points for a functor?
Let R : A −→ A be a
functor. In this section, we will analyze the notions of ﬁxed point and of
least ﬁxed point for a functor.

The question of ﬁxed points arises only with an endofunctor. We must
understand what sort of structure a ﬁxed point is and what it means to be a
least ﬁxed point. For a function on a set, say, we know exactly what a ﬁxed
point is. If the set is a partial order, we know exactly what a least ﬁxed point
is, if any. The relevant structure for ﬁxed points of functors turns out to be
the concept of algebra for the functor.

14.1.2 To see why a ﬁxed point for a functor does not have the obvious
deﬁnition, consider a possible deﬁnition of the natural numbers as the least

363

364

Algebras for endofunctors

ﬁxed point of the functor R on Set deﬁned by R(S) = 1 + S for a set S,
and for a function f : S −→ T , R(f ) = id1 +f : 1 + S −→ 1 + T . Here, 1 is a
terminal object and ‘+’ denotes disjoint union.

Even supposing that we have chosen a functorial deﬁnition for +, it is
not clear that any set is ﬁxed by this functor. If one is, it is not obvious that
it will look like the natural numbers. Moreover, this ﬁxed point will depend
on the surely irrelevant way in which the sums are deﬁned.

At ﬁrst it might seem that what is really wanted is a set S which is
isomorphic to 1 + S. This is certainly true for S = N; one isomorphism from
1 + N to N takes the unique element of the terminal object to 0 and each
element n ∈ N to n + 1. This approach is consonant with the categorical
perception that any use you could make of an object can equally well be
made of any isomorphic copy. Thus a ﬁxed point for a functor need only
be ﬁxed up to isomorphism, thereby avoiding any dependence on arbitrary
choices, for example of which particular categorical sum is used.

This leads to a second problem. Although N, and indeed any inﬁnite set,
is now a ﬁxed point, none is least in any obvious way. For example, any
inﬁnite set has a proper inﬁnite subset, which is also ﬁxed in the same way.
To understand what is going on here, we approach the question from another
angle.

14.1.3 Algebras for an endofunctor As above, we let A be a category
and R : A −→ A be an endofunctor. An R-algebra is a pair (A, a) where
a : RA −→ A is an arrow of A . A homomorphism between R-algebras (A, a)
and (B, b) is an arrow f : A −→ B of A such that

RA

A(cid:45)a

Rf

f

(cid:63)
RB

(cid:63)
B(cid:45)

b

commutes. This construction gives a category (R : A ) of R-algebras.

14.1.4 Deﬁnition An object (A, a) of (R : A ) for which the arrow a is
an isomorphism is a ﬁxed point for R.

Based on the perception that a category is a generalized poset, the fol-

lowing deﬁnition is reasonable.

14.1.5 Deﬁnition A least ﬁxed point of a functor R : A −→ A is an
initial object of (R : A ).

14.1 Fixed points for a functor

365

14.1.6 Example
In the case of the CPO P deﬁned in 2.4.8, the function
φ induces an endofunctor on the category C(P) corresponding to P. One
can prove by induction that the only algebra for the functor φ is the factorial
function itself, which is both A and φ(A). The algebra map a is the identity
map (the factorial function is less than or equal to itself in the CPO P).
Thus this algebra is clearly the initial (because it is the only) object of the
category of algebras.

If Deﬁnition 14.1.5 is to work, we have to show that an initial object of

(R : A ) is indeed a ﬁxed point.

14.1.7 Theorem [Lambek, 1970] Let R : A −→ A be a functor from a cat-
egory to itself. If (A, a) is initial in the category (R : A ), then a is an iso-
morphism.

Proof. Suppose (A, a) is initial. (RA, Ra) is an object of the category (R : A )
and hence there is a unique arrow f : (A, a) −→ (RA, Ra). This means that
the top square of the diagram

RA

A(cid:45)a

Rf

f

(cid:63)
R2A

(cid:63)
RA(cid:45)Ra

Ra

(cid:63)
RA

a

(cid:63)
A(cid:45)

a

commutes, while the bottom square patently does. Thus the whole rectangle
does and so a ◦ f : (A, a) −→ (A, a) is an arrow between R-algebras. But
(A, a) is initial and so has only the identity endomorphism. Thus a ◦ f = id.
Then the commutativity of the upper square gives us that

f ◦ a = Ra ◦ Rf = R(a ◦ f ) = R(id) = id

which means that f = a−1 and that a is an isomorphism.

14.1.8 Example Now let us look again at the functor R : Set −→ Set
which takes S to 1 + S. The natural numbers N form an algebra for R,
whose R-algebra structure is the function (0; s) : 1 + N −→ N, where 0 is the
function picking out 0 and s is the successor function.

This is in fact an initial algebra for R. For suppose f : 1 + S −→ S is an
R-algebra. The required unique R-algebra homomorphism h : N −→ S is the
function deﬁned inductively by h(0) = f (∗) (∗ is the unique element of the
singleton 1) and h(n + 1) = f (h(n)) (Exercise 1).

366

Algebras for endofunctors

Although N has many subsets which are ﬁxed up to isomorphism for
R, it has no proper subset that is ﬁxed under the given isomorphism (0; s);
that is one sense in which it is the ‘least’ ﬁxed point for R. Now a proper
subset ﬁxed under the isomorphism is the same thing as a proper subobject
in the category (R : A ), and no initial object of any category has a proper
subobject (Exercise 6 of Section 2.8); thus least ﬁxed points of functors all
have the property that they have no proper subobjects.

However, initiality is strictly stronger than the property of not hav-
ing proper subobjects. For example, the only object of the category corre-
sponding to the two-element monoid whose nonidentity element m satisﬁes
m2 = m is an object with no proper subobjects that is not initial. Thus be-
ing the least ﬁxed point of a functor in the sense we have deﬁned is a strong
requirement.

Another property of initial objects is that an initial object is determined
uniquely up to a unique isomorphism; thus least ﬁxed points in our sense have
the desirable property of being uniquely determined in the strongest possible
sense of uniqueness consistent with the philosophy of category theory: any
two least ﬁxed points are isomorphic in a unique way.

14.1.9 Fixed points of ﬁnitary functors Suppose we have a functor R
on the category of sets. We say that R is ﬁnitary if

FF–1 For each set S and each element x ∈ RS, there is a ﬁnite subset S0 ⊆ S
and an element x0 ∈ RS0 such that x = Ri0(x0) where i0 : S0 −→ S is
the inclusion.

FF–2 If also S1 is a ﬁnite subset of S with inclusion i1 and x1 ∈ RS1 with
x = Ri1(x1), then there is a ﬁnite subset S2 containing both S0 and
S1 with inclusions j0 : S0 −→ S2 and j1 : S1 −→ S2 such that Rj0(x0) =
Rj1(x1).

The real meaning of ﬁnitary is that everything is determined by what
happens on ﬁnite subsets. From the point of view of computer science, this
seems quite a reasonable hypothesis.

In fact, in the category of sets, FF–2 is unnecessary. We include it anyway
as a condition of this type is needed if this construction is generalized beyond
the category of sets. See Exercise 3 below.

14.1.10 Example The functor R : Set −→ Set deﬁned in 14.1.2 is ﬁni-
tary. Suppose x ∈ 1 + S. If x ∈ 1 we can take S0 = ∅ with inclusion i0 : ∅
−→ 1 + ∅. Then the unique element of the terminal object 1 is taken to itself
by Ri0, which is id1. If x ∈ S we can take S0 = {x} since Ri0 = i0 when
restricted to the component S0 of 1 + S0.

14.1 Fixed points for a functor

367

A ﬁnitary functor always has a ﬁxed point (Theorem 14.1.11 below). In
fact, the underlying functor from (R : Set) to Set has an adjoint; see [Barr,
1971] for details and generalizations.

We denote by η the unique arrow ∅ −→ R∅. We have a sequence

η

−−→ R(∅)

∅

R(η)

−−−−→ R2(∅)

R2(η)

−−−−−→ · · ·

Rn−1(η)

−−−−−−−→ Rn(∅)

Rn(η)

−−−−−→ · · ·

(14.1)
The colimit of this sequence (which would be the union if the arrows were
inclusions) is a set we will call Z.

14.1.11 Theorem If R is a ﬁnitary endofunctor on Set and Z is the
colimit of (14.1), then there is an R-algebra structure z : RZ −→ Z which is
an initial R-algebra.

The crucial point is that when R is ﬁnitary, it commutes with the colimit

that deﬁnes Z so that RZ is the colimit of the sequence

R(∅) −→ R2(∅) −→ R3(∅) · · ·

which is canonically isomorphic to Z. The structure map z : RZ −→ Z is this
isomorphism. The proof that this works is fairly technical and is omitted.

14.1.12 Example Let R be the functor of 14.1.2. Then the sequence (14.1)
comes down to

0 −→ 1 −→ 2 −→ · · · −→ n −→ · · ·

where by n we mean the sum 1 + 1 + · · · + 1 (n summands). The arrow from
n to n + 1 is given by the injection into the sum. This gives rise to the set
N of natural numbers with successor as the operation.

14.1.13 Example Here is an example of a nonﬁnitary functor. Let P :
Set −→ Set take a set S to the set of subsets of S. If f : S −→ T is a function,
then P f takes the subset S0 ⊆ S to f (S0) ⊆ T . P is not ﬁnitary because
when S is inﬁnite, not every subset of S (in fact, no inﬁnite subset of S) is
a subset of a ﬁnite subset of S.

14.1.14 The reader may wonder why it was necessary to introduce the
category of all R-algebras when we were interested only in the ﬁxed points.
There are two answers to that question.

First, if A is complete with an initial object, then (R : A ) is complete as
well and the underlying functor U : (R : A ) −→ A preserves all limits. This
does not actually prove that U has an adjoint, but it makes it highly likely.
The second reason is that the construction of (R : A ) is part of the
construction of the category of algebras for a triple, which is carried out
in 14.4.2.

368

Algebras for endofunctors

14.1.15 Exercises

1. Show that the function h deﬁned in 14.1.8 is the unique R-algebra homo-
morphism from (0; s) : 1 + N −→ N to f : 1 + S −→ S.

2. Let (S, ≤) be a total order and f : S −→ S a monotone function. Let
C(S, ≤) be the category determined by (S, ≤) as in 2.3.1. Show that f de-
termines an endofunctor, the objects of (f : S) are the x ∈ X for which
f (x) ≤ x and the least ﬁxed point is the same as the one deﬁned here.

3. a. Show that whenever f : S −→ T is an injective function in the category
of sets and S (cid:54)= ∅, then there is a g : T −→ S such that g ◦ f = idS.

b. Show that if F : Set −→ C is a functor to an arbitrary category and

f : S −→ T is an injective function in Set, then F (f ) is a monomorphism.

c. Show that condition FF–2 of 14.1.9 is unnecessary.

14.2 Recursive categories

In this section, we discuss two ways involving algebras for functors in which
recursion can be modeled in a category.

14.2.1 Recursion in functional programming languages In 2.2.1,
we described how to represent a functional programming language as a cate-
gory. The major missing piece from that description was how to produce po-
tentially inﬁnite programs. This is done in traditional languages using while
loops and their relatives, but can also be done in a ﬂexible way using recur-
sion, which is available in cartesian closed categories with a natural numbers
object (see Section 5.5). However, the construction of function space objects
in cartesian closed categories can lead to noncomputable constructions.

J. R. B. Cockett has proposed axioms on a category which directly allow a
limited form of recursion, which in the presence of mild additional hypotheses
preserves a form of computability (Theorem 14.2.9). The discussion that
follows is based on [Cockett, 1989], [Cockett, 1990].

14.2.2 Let C be a category with ﬁnite products. Then for every object A
there is a functor A × − which takes an object X to A × X and an arrow
f : X −→ Y to idA ×f : A × X −→ A × Y . An algebra x : A × X −→ X for this
functor is an A-action. For each object A there is a category act(A) which
is the category of algebras for the functor A × −. There is an underlying
functor UA : act(A) −→ C which takes x : A × X −→ X to X and an arrow
f : (x : A × X −→ X) −→ (y : A × Y −→ Y ) to f .

14.2 Recursive categories

369

14.2.3 Deﬁnition A category C is recursive if for every object A the
underlying functor UA has a left adjoint FA : C −→ act(A).

For an object B, denote UA(FA(B)) by rec(A, B); for f : B −→ C, we get

an arrow

rec(A, f ) = UA(FA(f )) : rec(A, B) −→ rec(A, C)

The algebra FA(B) is an algebra structure

r(A, B) : A × rec(A, B) −→ rec(A, B)

The unit of the adjunction has component r0(A, B) : B −→ rec(A, B) at an
object B. In particular, rec(1, 1) is a natural numbers object (Exercise 2).

The object rec(A, B) is characterized by the following universal mapping
property. If t0 : B −→ X and t : A × X −→ X are arbitrary arrows, then there
is a unique f : rec(A, B) −→ X such that the following diagram commutes.

r0(A, B)

(cid:161)

B

(cid:64)
t0

(cid:64)(cid:64)(cid:82)

(cid:190)r(A, B)

A × rec(A, B)

rec(A, B)
(cid:161)(cid:161)(cid:181)

f

(cid:63)
(cid:63)
X

(cid:190)

idA ×f

(cid:63)
A × X

t

14.2.4 Set is recursive. You can check that in Set, rec(A, B) is (up to
isomorphism) the set of pairs of the form (l, b) where l is a list of elements
of A (including the empty list) and b ∈ B, and r(A, B) is the function which
takes (a, (l, b)) to (cons(a, l), b), where cons is the function which adjoins a
to the list l at the front. The unit r0(A, B) : B −→ rec(A, B) takes b to ((cid:104)(cid:105), b).
In particular, in Set, A∗ = rec(A, 1) is the set of lists of elements of A.
It has the right properties to be regarded as lists of A in any category; for
example, Cockett [1990] shows how to deﬁne the head and tail of a list in
recursive categories. Because of this, it is natural to denote rec(A, 1) by A∗
in a recursive category.

14.2.5 Now for objects A and B of a recursive category C , the projection
p2 : A × B −→ B is an algebra for A × −. We have the identity arrow of B and
the universal mapping property then produces a unique arrow a : rec(A, B)

370

Algebras for endofunctors

−→ B with the property that

rec(A, B)
(cid:161)(cid:161)(cid:181)

r0(A, B)

(cid:190)r(A, B)

A × rec(A, B)

(cid:161)

B

(cid:64)

idB

(cid:64)(cid:64)(cid:82)

a

(cid:63)
(cid:63)
B

(cid:190)

idA ×a

(cid:63)
A × B

p2

commutes. There is then an arrow

c(A, B) = (cid:104)rec(A, (cid:104)(cid:105)), a(cid:105) : rec(A, B) −→ rec(A, 1) × B

14.2.6 Deﬁnition Let C be a recursive category. If for all A and B,
c(A, B) is an isomorphism, then C has local recursion. A locally recur-
sive category is a recursive category with local recursion for which every
slice category C /C is recursive. C is a locos if it is coherent (see 9.6.8) and
locally recursive.

The deﬁnition of locally recursive implies that rec(A, B) ∼= rec(A, 1) ×

B = A∗ × B. The discussion in 14.2.4 shows that this is true in Set.

The axioms on a locos allow many other constructions. Speciﬁcally, there
is a whole class of functors for which the underlying functor from the algebra
category has a left adjoint.

14.2.7 Deﬁnition The class of polynomial endofunctors on a cate-
gory with ﬁnite sums and products is the least class that contains the con-
stant endofunctors and the identity functor and is closed under the opera-
tions of ﬁnite products and sums.

14.2.8 Proposition Let C be a locos and P a polynomial functor. Then
the underlying functor U : (P : C ) −→ C has a left adjoint.

This allows the construction of free objects generated by an object. Thus

if D is an object and T is the functor for which

T (X) = D + X × D × X

the free object on the terminal object 1 has a structure map

[D + F (1) × D × F (1)] −→ F (1)

It can be interpreted as the object of binary trees with data at the root, and
the structure map constructs such trees from either a datum or a datum and
two given trees. Thus a locos allows a type of initial algebra semantics.

14.2 Recursive categories

371

Another property of locoses is that if you start with computable things
the constructions of a locos give you computable things in a precise sense.
This requires a deﬁnition. In any category with ﬁnite products, an object
D is decidable if the diagonal ∆ : D −→ D × D (which is a subobject of
D × D) has a complement in D × D (see 9.6.2). Thus the law of the excluded
middle applies internally to equality of elements of a decidable object: two
elements are either equal (factor through the diagonal) or not equal (factor
through the complement of the diagonal).

In a category representing computable objects, one can assume that each
object can be generated eﬀectively: in other words, each object is recursively
enumerable. Of course, the diagonal is then recursively enumerable – one
generates elements of D and for each element forms (d, d) (the word ‘element’
can be taken in various senses here). If the object is decidable, then the
complement of the diagonal exists, so that one can generate all the pairs of
unequal elements. Then by a well known theorem one can decide whether
two elements are the same: hence the name ‘decidable’.

14.2.9 Theorem If S is a collection of decidable objects in a locos, and
no sublocos of the locos contains S , then every object of the locos is decidable.

For the proof, see [Cockett, 1989]. Locoses may be described as models
of an FL sketch, so that there is an initial locos. The theorem above implies
that in the initial locos every object is decidable.

14.2.10 Categorical dynamics An input process in a category C is
an endofunctor R for which the underlying functor (R : C ) −→ C has a left
adjoint. An object of the category (R : C ) is called an R-dynamic, the
category itself is called the category of R-dynamics and an arrow in the
category is called a dynamorphism. A machine in C is a 7-tuple M =
(R, C, c, I, τ, Y, β) in which R is an input process, (C, c) is an R-dynamic,
the object I of C is called the initial state object (not to be confused with
an initial object of the category) and τ : I −→ C the initial state arrow, and
Y is called the output object and β : C −→ Y is the output arrow.

14.2.11 Example Let A be an object of any recursive category. Then by
deﬁnition the functor R deﬁned by R(C) = A × C and R(f ) = idA ×f is an
input process. Thus ﬁnite state machines can be deﬁned in an arbitrary recur-
sive category. Many deﬁnitions connected with ﬁnite state machines can be
given in a recursive category. For example, a machine M = (R, C, c, I, τ, Y, β)
is reachable if τ factors through no proper subobject of the algebra (C, c).

In particular, let the recursive category be the category of sets and
let A be a ﬁnite set thought of as an alphabet. An algebra for R is a
function δ : A × C −→ C for some set C. By deﬁning δ∗((cid:104)(cid:105), q) = q and

372

Algebras for endofunctors

δ∗(aw, q) = δ(A, δ∗(w, q)), one has an action of the free monoid A∗ on C.
Setting I to be a one-element set, one obtains the usual deﬁnition of state
transition machine used in the automata theory literature. Reachability here
has its usual meaning, that one can reach any state from the start state by
a sequence of operations (if not, the states that can be so reached form a
proper subalgebra containing the image of τ ).

The concept of R-dynamic is much more general than this. For example,
one can have several ‘start’ states by choosing I to be a bigger set. More
drastically, one could use a diﬀerent functor R, for example R(C) = C × C.
This discussion of categorical dynamics is from [Arbib and Manes, 1975],

which should be consulted for details. See also [Arbib and Manes, 1980].

14.2.12 Exercises

1. Prove the claims in 14.2.4.

2. Prove that in a recursive category, rec(1, 1) is a natural numbers object.
(Hint: Use the unit of the adjunction for 0.)

14.3 Triples

We now describe a structure based on an endofunctor which has turned out
to be an important technical tool in studying toposes and related topics. It
is an abstraction of the concept of adjoint and in a sense an abstraction of
universal algebra (see the remarks in ﬁne print at the end of 14.4.3 below).

14.3.1 Deﬁnition A triple T = (T, η, µ) on a category A consists of a
functor T : A −→ A , together with two natural transformations η : id −→ T
and µ : T 2 −→ T for which the following diagrams commute.

T 2(cid:45)ηT

(cid:190) T η

T

T

T 3

T 2(cid:45)T µ

(cid:64)
=

(cid:64)

µ

(cid:161)
=

(cid:161)

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

(cid:63)
T

µT

µ

(14.2)

(cid:63)
T 2

(cid:63)

T(cid:45)

µ

Here, ηT and T η are deﬁned as in 4.4.2 and 4.4.3.

The transformation η is the unit of the triple and µ is the multiplica-
tion. The left diagram constitutes the (left and right) unitary identities
and the right one the associative identity. The reason for these names
comes from the analogy between triples and monoids. This will be made
clear in 14.3.4.

14.3 Triples

373

Another widely used name for triple is ‘monad’. However, they have

nothing to do with the monads of Robinson’s theory of inﬁnitesimals.

14.3.2 The triple arising from an adjoint pair An adjoint pair gives
rise to a triple on the domain of the left adjoint.

14.3.3 Proposition Let U : B −→ A and F : A −→ B be functors such
that F
U with η : id −→ U F and (cid:178) : F U −→ id the unit and counit, respec-
tively. Then (U F, η, U (cid:178)F ) is a triple on A .

We leave the proof as an exercise. Note that U (cid:178)F : U F U F −→ U F , as

required for the multiplication of a triple with functor U F .

Conversely, every triple arises in that way out of some (generally many)

adjoint pair. See Section 14.4 for two ways of constructing such adjoints.

14.3.4 Representation triples Let M be a monoid. The representation
triple T = (T, η, µ) on the category of sets is given by letting T (S) = M × S
for a set S. ηS : S −→ T (S) = M × S takes an element s ∈ S to the pair
(1, s). We deﬁne µS by (µS)(m1, m2, s) = (m1m2, s) for s ∈ S, m1, m2 ∈ M .
Thus the unit and multiplication of the triple arise directly from that of
the monoid. The unitary and associativity equations can easily be shown to
follow from the corresponding equations for the monoid.

The standard way of getting this triple from an adjoint pair is by using
the underlying and free functors on M -sets (see 3.2.1). If S and T are M -sets,
then a function f : S −→ T is said to be M -equivariant if f (ms) = mf (s)
for m ∈ M, s ∈ S. For a ﬁxed monoid M , the M -sets and the M -equivariant
functions form a category, called the category of M -sets.

The free M -set generated by the set S is the set M ×S with action given
by m(cid:48)(m, s) = (m(cid:48)m, s). Using Theorem 13.3.5, one can show immediately
that this determines a functor left adjoint to the underlying set functor on
the category of M -sets. The triple associated to this adjoint pair is the one
described above.

14.3.5 Cotriples A cotriple G = (G, (cid:178), δ) in a category A is a triple in
A op. Thus G is an endofunctor of A and (cid:178) : G −→ id and δ : G −→ G2 are
natural transformations such that

G

(cid:161)

(cid:64)

δ
(cid:63)
G2

(cid:64)

=
(cid:64)
(cid:64)(cid:82)
G(cid:45)

G(cid:178)

G

G2(cid:45)δ

δ

(cid:63)
G2

δG
(cid:63)
G3(cid:45)

Gδ

(14.3)

(cid:161)

=
(cid:161)

(cid:161)(cid:170)
(cid:190)

G

(cid:178)G

Cotriples are used in Chapter 16.

374

Algebras for endofunctors

14.3.6 Exercises

1. Let (P ≤) be a poset and T = (T, η, µ) a triple on the category C(P, ≤).
Show that for any x ∈ P, x ≤ T (x) and T (T (x)) = T (x). (Such a function
T is called a closure operator.)

2. Prove Proposition 14.3.3.

3. Let T : Set −→ Set be the functor which takes a set A to the Kleene
closure A∗ and a function f : A −→ B to the function f ∗ : A∗ −→ B∗ deﬁned
in Section 2.5.7. Let ηA : A −→ A∗ take an element a to the one-element
string (a), and let µA : A∗∗ −→ A∗ take a string (s1, s2, . . . , sk) of strings to
the concatenated string s1s2 · · · sn in A∗ obtained in eﬀect by erasing inner
brackets: thus ((a, b), (c, d, e), (), (a, a)) goes to

(a, b)(c, d, e)()(a, a) = (a, b, c, d, e, a, a)

In particular, µA((a, b)) = (a, b). Show that η : id −→ T and µ : T ◦ T −→ T
are natural transformations, and that (T, η, µ) is a triple.

14.4 Factorizations of a triple

14.4.1 The Kleisli category for a triple Let T = (T, η, µ) be a triple
on C . We describe here a construction which exhibits the triple as coming
from an adjoint. This construction, which is due to Kleisli [1965], has proven
to be quite useful in theoretical computer science.

We deﬁne a category K = K (T) which has the same objects as C . If
A and B are objects of C , then an arrow in K from A to B is an arrow A
−→ T B in C . The composition of arrows is as follows. If f : A −→ T B and
g : B −→ T C are arrows in C , we let their composite in K be the following
composite in C :

f

−−→ T B

T g

−−−→ T 2C

µC

−−−→ T C

A

The identity of the object A is the arrow ηA : A −→ T A. It can be shown
that this deﬁnes a category. Moreover, there are functors U : K (T) −→ C
and F : C −→ K (T) deﬁned by U A = T A and U f = µB ◦ T f , where B is
the codomain of f , and F A = A and for g : A −→ B, F g = T g ◦ ηA. Then F
is left adjoint to U and T = U ◦ F . The proof is left as an exercise.

14.4.2 Eilenberg–Moore algebras Here is a second way, due to Eilen-
berg and Moore [1965] of factoring every triple as an adjoint pair of functors.
In mathematics, this construction has been much more interesting than the
Kleisli construction, but in computer science it has been quite the opposite.

Let T = (T, η, µ) be a triple on A . A T -algebra (A, a) is called a T-algebra

if the following two diagrams commute:

14.4 Factorizations of a triple

375

T 2A

T A(cid:45)µA

T a

a

(cid:63)
T A

(cid:63)
A(cid:45)

a

T A(cid:45)ηA

A

(cid:64)
=

(cid:64)

(cid:64)

(cid:64)(cid:82)

a

(cid:63)
A

An arrow (homomorphism) between T-algebras is the same as an arrow
between the corresponding T -algebras. With these deﬁnitions, the T-algebras
form a category traditionally denoted A T and called the category of T-
algebras.

There is an obvious underlying functor U : A T −→ A with U (A, a) = A
and U f = f . This latter makes sense because an arrow of A T is an arrow
of A with special properties. There is also a functor F : A −→ A T given by
F A = (T A, µA) and F f = T f . Some details have to be checked; these are
included in the following.

14.4.3 Proposition The function F above is a functor left adjoint to U .
The triple associated to the adjoint pair F

U is precisely T.

The proof is left as an exercise.

By a theorem of Linton’s, every equationally deﬁned category of one-sorted
algebraic structures is in fact equivalent to the category of Eilenberg–Moore
algebras for some triple in Set ([Barr and Wells, 1985], Theorem 5 of Section
4.3). (See Exercise 3.) In fact, the converse is true if inﬁnitary operations are
allowed (but then a hypothesis has to be added on the direct part of the theorem
that there is only a set of operations of any given arity).

14.4.4 The Kleisli category and free algebras The Kleisli category of
a triple T = (T, η, µ) is equivalent to the full subcategory of free T-algebras.
Its deﬁnition makes it clear that the arrows are substitutions.

As an example, consider the list triple of Exercise 3, Section 14.3. An
arrow f : A −→ B (here A and B are sets) of the Kleisli category is a set
function A −→ T B, so that it associates a string of elements of B to each
element of A. Suppose A = {a, b} and B = {c, d, e}, and that f (a) = cddc
and f (b) = ec. Then T f : T A −→ T T B takes, for example, the string abba to
(cddc)(ec)(ec)(cddc), the result of substituting cddc for a and ec for b in abba.
Then µ takes that string to cddcececcddc. It is instructive in this situation
to think of µ as carrying out a computation. In this case the computation
is carried out using the (only) monoid operation, since in fact the algebras
for this triple are monoids (Exercise 3). Thus one can think of the objects

376

Algebras for endofunctors

of the Kleisli category as computations. This is more compelling if one uses
a triple arising from algebraic structures such as rings that abstract some of
the properties of numerical addition and multiplication; then the objects of
the free algebra are polynomial expressions and µ evaluates the polynomial.
An important idea for developing this point of view is the notion of ‘strong
monad’ [Kock, 1972], which has been developed by Moggi [1989, 1991b]
and others [Cockett and Spencer, 1992], [Mulry, 1992]. Other applications of
triples (monads) in computing science can be found in the survey [Rydeheard
and Burstall, 1985], as well as [Moggi, 1991a], [Power, 1990b], [Wadler, 1989],
[L¨uth and Ghani, 1997] and [Wadler, 1992] (the latter has many references
to the literature).

14.4.5 Exercises

1. Show that ηA : A −→ T A is the identity on A in K (T).

2. Show that the composition deﬁned for K (T) is associative.
3.† Let (T, η, u) be the triple in Set deﬁned in Exercise 3 of Section 14.3.

a. Show that an algebra for this triple is a monoid: speciﬁcally, if α : T (A)
−→ A is an algebra, then the deﬁnition ab = α(a, b) makes A a monoid, and
up to isomorphisms every monoid arises this way.

b. Show that algebra homomorphisms are monoid homomorphisms, and

that every monoid homomorphism arises this way.
4.† Prove Proposition 14.4.3.

14.5 Scott domains

In [Scott, 1972], a general construction of a great many models of the untyped
λ-calculus is given. (See also [Scott, 1982].) One version of ﬁnding such a
model involves ﬁnding an object D in a cartesian closed category with the
property that D ∼= [D −→ D]. This is an example of ﬁnding a model for
computation in a category other than the category of sets. Another such
example involves the category of modest sets (15.8.3).

This section requires only Section 14.1 to be read, and is not needed in

the rest of the book.

14.5.1 The diﬃculty with ﬁnding an object D ∼= [D −→ D] using a ﬁxed
point of a functor is that the operation that takes D to [D −→ D] is not a
functor since an arrow D −→ E induces arrows [D −→ D] to [D −→ E] and [E
−→ D] to [D −→ D] as well as others (see Proposition 6.2.1), but no arrow in
either direction between [D −→ D] and [E −→ E]. There is an ingenious trick
due to Smyth and Plotkin [1983] to solve this problem.

14.5 Scott domains

377

Some categories have additional structure on their hom sets; the hom set
has the structure of an object from some category V and the hom functors
are arrows of V . Such a category is said to be enriched over V . (The actual
deﬁnition of enriched is more abstract than that.) In particular, Cat, and any
other 2-category, is enriched over Cat itself, since its hom sets are themselves
categories (with the arrows as objects and the natural transformations as
arrows) and the hom functors preserve the extra structure. (See Section 4.8
and [Kelly, 1982a].) We will not deﬁne the general concept of enriched here,
but will concentrate on a particular type of poset-enriched category (see
Example 4.8.13).

14.5.2 Deﬁnition A category C is a Smyth–Plotkin category under
the following conditions.

SP–1 C is cartesian closed.
SP–2 Hom(A, B) is a poset for each pair of objects A, B of C .
SP–3 If f : A −→ B, g, h : B −→ C, k : C −→ D and g ≤ h, then both g ◦ f ≤

h ◦ f and k ◦ g ≤ k ◦ h.

SP–4 If g, h : B −→ C with g ≤ h, then for any A, both

[g −→ A] ≤ [h −→ A] : [C −→ A] −→ [B −→ A]

(note that the order is not reversed) and

[A −→ g] ≤ [A −→ h] : [A −→ B] −→ [A −→ C]

SP–5 C has limits and colimits along countable chains.
SP–6 If A = lim Ai, then the isomorphism

Hom(B, A) ∼= lim Hom(B, Ai)

for each object B is an order isomorphism.

SP–7 If A = colim Ai, then the isomorphism

Hom(A, C) ∼= lim Hom(Ai, C)

for each object C is an order isomorphism.

The constructions in this section work if we replace cartesian closed categories
by the symmetric monoidal closed categories that are the subject of the next
chapter.

378

Algebras for endofunctors

14.5.3 To a Smyth–Plotkin category C we associate two new categories
LA(C ) and RA(C ). LA(C ) (for left adjoint) has the same objects as C .
A homomorphism A −→ B is a pair of arrows of C , f : A −→ B and g : B
−→ A such that idA ≤ g ◦ f and f ◦ g ≤ idB. RA(C ) is deﬁned similarly
but with inequalities reversed, so that an arrow A −→ B is a pair (f, g) with
g ◦ f ≤ idA and idB ≤ f ◦ g. These really do mean left and right adjoint,
respectively, when we consider the partially ordered sets as categories.

If (f, g) : A −→ B is in either LA(C ) or RA(C ), then f and g determine
each other. For suppose that both (f, g) and (f, h) are arrows of LA(C ),
then h ≤ g ◦ f ◦ h ≤ g and g ≤ h ◦ f ◦ g ≤ h, using the deﬁnition of homo-
morphism in LA(C ) as well as SP–3 above. The proof that g determines
f and the proofs in RA(C ) are similar. A second proof follows from the
fact that right and left adjoints determine each other up to isomorphism
(see 13.3.4) and isomorphic objects in a poset are equal.

Next we observe that LA(C )op ∼= RA(C ). In fact, an arrow in LA(C )
from A to B is a pair (f, g) where id ≤ g ◦ f and f ◦ g ≤ id. This, by
deﬁnition, is an arrow from B −→ A in LA(C )op. On the other hand an
arrow from B −→ A in RA(C ) is a pair (g, f ) where g : B −→ A and f : A
−→ B satisfy f ◦ g ≤ id and id ≤ g ◦ f . Thus the isomorphism is the one that
takes the pair (f, g) to the pair (g, f ).

Now suppose that {(fi, gi) : Ai −→ A} is a cocone in LA(C ). Purely
formally, this is a colimit if and only if the cone {(fi, gi) : A −→ Ai} is a limit
cone in m LA(C )op. By the isomorphism above this is true if and only if the
cone {(gi, fi) : A −→ Ai} is a limit cone in RA(C ).

14.5.4 Deﬁnition The arrow (f, g) of either LA(C ) or RA(C ) is a re-
tract if g ◦ f = id and a coretract if f ◦ g = id.

14.5.5 Theorem Let C be a Smyth–Plotkin category. Suppose that the
hom sets in C have least upper bounds along countable increasing chains
and that

A0 −→ A1 −→ A2 −→ · · · −→ An −→ · · ·

(14.4)

is a countable retract chain in LA(C ) with arrows (hji, kij) : Ai −→ Aj for
i ≤ j. Suppose A is the colimit in C with transition arrows fi : Ai −→ A.
Then there are (necessarily unique) arrows gi : A −→ Ai such that (fi, gi) is
a retract in LA(C ) for each i, and such that A is the colimit of (14.4) in
LA(C ).

Dually, suppose that

· · · −→ An −→ An−1 −→ · · · −→ A1 −→ A0

(14.5)

is a countable coretract chain in RA(C ) with arrows (kji, hij) : Ai −→ Aj
for j ≤ i. Suppose A is the limit in C with transition arrows gi : A −→ Ai.

14.5 Scott domains

379

Then there are (necessarily unique) arrows fi : Ai −→ A such that (gi, fi) is
a coretract in RA(C ) and such that A is the limit of (14.5) in RA(C ).

Proof. The two statements are dual to each other, as are their proofs. We
sketch the proof of the second. To deﬁne for each i an arrow fi : Ai −→ A
using the limit property, we have to give a consistent family of arrows fji :
Ai −→ Aj. We let fji = hji for i < j, fji = kji for i > j and fii = id. (In
point of fact, it is not hard to show that these arrows need be deﬁned only
for suﬃciently large j so that only the case i < j is important.) To show
consistency with the cone, we calculate for i < j < l,

kjl ◦ fli = kjl ◦ hli = kjl ◦ hlj ◦ hji = id ◦ hlj = flj

The cases where j < i ≤ l and i ≤ j < l are similar (easier, in fact).
The result is an arrow fi : Ai −→ A such that gj ◦ fi = fji. In particular,
gi ◦ fi = id. Finally we have for i < j, gj ◦ fi ◦ gi = fji ◦ gi = hji ◦ gi = hji ◦
kij ◦ gj ≤ gj = gj ◦ id. At this point, we invoke the fact that the partial
order on Hom(A, A) is the limit of those on Hom(A, Aj) so that it follows
that fi ◦ gi ≤ id.

This deﬁnes the arrows fi. To prove that this is a limit in RA(C ) is
tedious, but not hard. If B is an object and (ri, si) is a consistent family of
arrows in RA(C ), then since A is the limit in C , there is a unique arrow r : B
−→ A such that ri = gi ◦ r for all i. For i ≤ j, we have si ◦ gi = sj ◦ hji ◦ kij ◦
gj ≤ sj ◦ gj. Thus the sequence of arrows si ◦ gi ∈ Hom(A, B) is a countable
increasing sequence and has a sup we call s. To show that s ◦ r ≥ id it is
suﬃcient to show that gj ◦ s ◦ r ≥ gj for each j. gj ◦ s ◦ r = gj ◦ sup si ◦
gi = supi gj ◦ si ◦ gi. Now to do something with the sup, it suﬃcient to
stick to j > i. For such i, supi gj ◦ si ◦ gi = supi kji ◦ si ◦ ri ◦ gi ≥ supi kji ◦
gi = supi gj = gj. Also s ◦ r = sup sn ◦ gn ◦ r = sup sn ◦ rn ≤ id since every
sn ◦ rn ≤ 1. We note that if every (rn, sn) is a coretract, that is rn ◦ sn = id,
then the same is true of (r, s). The uniqueness of (r, s) follows from the
uniqueness of r in C since r determines s.

14.5.6 If (f, g) : D −→ E is a homomorphism in LA(C ), the diagram

[D −→ D]

[D, f ]

(cid:45)

[D −→ E]

[g, D]

[g, E]

(cid:63)
[E −→ D]

(cid:63)
[E −→ E]

(cid:45)

[E, f ]

380

Algebras for endofunctors

commutes and determines an arrow [D, D] −→ [E, E]. This idea can be used
directly to ﬁnd a ﬁxed point for this endoarrow functor. However, it turns
out that a slight modiﬁcation of this idea gives a more useful conclusion.

Let us begin with an object A of C with A (cid:54)= 1 and A ∼= A × A. Assume
further that there is a retract pair (h, k) : A −→ [A −→ A] in LA(C ). Deﬁne a
functor F : LA(C ) −→ LA(C ) that takes B to [B −→ A] and (f, g) : B −→ C
to ([g, A], [f, A]) from [B −→ a] to [C −→ a]. If (f, g) is a retract pair, so is
F (f, g).

Consider the sequence

A −→ F (A) −→ F 2(A) −→ · · · −→ F n(A) −→ F n+1(A) −→ · · ·

with (hn, kn) = F n(h, k) : F n(A) −→ F n+1(A). This is a countable retract
chain (the arrow from the ith term to the jth is just the composite of the
successive arrows). Let B be the colimit of this chain in C . Then we know
that this is also the colimit in LA(C ) and that B is also the limit of the
sequence

· · · −→ F n(A) −→ · · · −→ F (A) −→ A

in C . We claim that F commutes with this colimit. In fact, when the object
C is the colimit in C of the sequence

C0 −→ C1 −→ · · · −→ Cn −→ · · ·

[C, A] is the limit of the sequence

· · · −→ [Cn −→ A] −→ · · · −→ [C1 −→ A] −→ [C0 −→ A]

(14.6)

because [−, A] : C op −→ C is a right adjoint and thus preserves limits (see
13.3.7). But (14.6) being a limit is equivalent to the sequence

[C0 −→ A] −→ [C1 −→ A] −→ · · · −→ [Cn −→ A] −→ · · ·

being a colimit. But this is just

F (A0) −→ F (A1) −→ · · · −→ F (An) −→ · · ·

which shows that F preserves the colimit of a countable chain of retracts. It
follows that F (B) ∼= B.

Now we have that B ∼= [B −→ A]. We supposed that A ∼= A × A so that
B × B ∼= [B −→ A] × [B −→ A] ∼= [B, A × A] ∼= [B −→ A] ∼= B. Also, [B −→
B] ∼= [B −→ [B −→ A]] ∼= [(B × B) −→ A] ∼= [B −→ A] ∼= B. Thus B is not
only a solution to B ∼= [B −→ B], but simultaneously to B ∼= B × B.

14.5 Scott domains

381

14.5.7 Examples Many categories of posets satisfy Theorem 14.5.5. Let
C be a (not necessarily full) subcategory of posets and order-preserving
maps. The set of order-preserving functions between two objects of C is
partially ordered by saying that f ≤ g if f (x) ≤ g(x) for all x in the domain
of f . Whether C is cartesian closed and satisﬁes the other conditions of the
theorem we have just proved to be useful is something that has to be proved
in each special case.

Here is the example that especially interests us. Let C be the category
whose objects are ω-CPOs and whose arrows are functions that preserve
countable sups as described in 2.4.3. It is not hard to see that this category
is cartesian closed. In fact, we know that there is a one to one correspondence
between functions A × B −→ C and functions A −→ [B −→ C]; the thing to do
is to show that this isomorphism remains when everything in sight preserves
countable sups and that the isomorphism itself preserves countable sups.
We leave this as an exercise. The category has limits computed pointwise.
Colimits are not quite so simple. The easiest way to compute a colimit is
to ﬁrst compute the colimit as a poset and then add freely the colimits of
countable increasing sequences.

We want to ﬁnd an object A (cid:54)= 1 with A ∼= A × A and A having an arrow
A −→ [A −→ A] in LA(C ). Take any object A0 of C with A0 (cid:54)= 1 and having
a least element ⊥. Then the product A of countably many copies of A0 will
have the property that A ∼= A × A. For example, the function that takes
the countable sequence (a0, a1, a2, a3, . . .) to ((a0, a2, a4, . . .), (a1, a3, a5, . . .))
is an isomorphism.

Since A0 has a least element, so does A. Let f : A −→ [A −→ A] be the
arrow that takes an element to the constant function at that element which is
certainly an order-preserving function. Let g : [A −→ A] −→ A take an order-
preserving function to its value at ⊥. Then it is immediate that g ◦ f = id
and that f ◦ g ≤ id so we have an arrow of LA(C ).

We can now apply the construction of 14.5.6 to get an ω-CPO D for

which D ∼= D × D ∼= [D −→ D].

14.5.8 Exercises
1.† Show that the category of ω-CPOs and functions that preserve countable
sups is cartesian closed.
2.† Show that every poset freely generates an ω-CPO. (Let P be a poset.
Let (cid:98)P denote the set of all countably increasing chains of P . If c = {cn} and
n} are two such chains, say that c ≤ c(cid:48) if every element of c is less
c(cid:48) = {c(cid:48)
than or equal to some element of c(cid:48). Say that c = c(cid:48) if both c ≤ c(cid:48) and c(cid:48) ≤ c.)
3.† Show that the category of ω-CPOs has limits (computed pointwise) and
colimits. Assume that the category of posets has colimits.

382

Algebras for endofunctors

4. A subset of a poset is called directed or ﬁltered if every pair of elements
has a common upper bound in the subset. Show that a poset is countably
chain complete if and only if every countable directed subset has a least
upper bound.

15
Toposes

A topos is a cartesian closed category with some extra structure which pro-
duces an object of subobjects for each object. This structure makes toposes
more like the category of sets than cartesian closed categories generally are.
Toposes, and certain subcategories of toposes, have proved attractive for
the purpose of modeling computation. A particular reason for this is that
in a topos, a subobject of an object need not have a complement. One of
the fundamental facts of computation is that it may be possible to list the
elements of a subset eﬀectively, but not the elements of its complement (see
[Lewis and Papadimitriou, 1981], Theorems 6.1.3 and 6.1.4.). Sets which
cannot be listed eﬀectively do not exist for computational purposes, and
toposes provide a universe of objects and functions which has many nice set-
like properties but which does not force complements to exist. We discuss
one speciﬁc subcategory of a topos, the category of modest sets, which has
been of particular interest in the semantics of programming languages.

Toposes have interested mathematicians for other reasons. They are an
abstraction of the concept of sheaf, which is important in pure mathematics.
They allow the interpretation of second-order statements in the category
in an extension of the language associated to cartesian closed categories in
Chapter 6. This fact has resulted in toposes being proposed as an alternative
to the category of sets for the foundations of mathematics. Toposes can
also be interpreted as categories of sets with an internal system of truth
values more general than the familiar two-valued system of classical logic;
this allows an object in a topos to be thought of as a variable or time-
dependent set, or as a set with various degrees of membership. In particular,
most ways of deﬁning the category of fuzzy sets lead to a category which
can be embedded in a topos.

Sections 15.1 and 15.2 describe the basic properties of toposes, for the
most part without proof. Section 15.3 takes a closer look at an aspect of
toposes which make many of them a better model of computation than, for
example, Set.

Sections 15.4 and 15.5 describe a special case of categories of sheaves
which makes the connection with sets with degrees of membership clear. The
category of graphs is discussed as an example there. Section 15.6 describes
the connection with fuzzy sets.

383

384

Toposes

In Section 15.7 we describe category objects in a category, a notion that
is needed in Section 15.8, which is a brief description of the realizability
topos and modest sets.

This chapter depends on Chapters 1 through 6, Chapter 9, and Chap-

ter 13. In addition, Section 15.7 needs 10.1.5, 11.1 and 11.2.

Sections 15.1 and 15.2 are needed in all the remaining sections. After that,
the chapter consists of four independent units: Section 15.3, Sections 15.4
and 5, Section 15.6 and Sections 15.7 and 8.

Basic properties of toposes are [Johnstone, 1977], [Barr and Wells, 1985],
[Lambek and Scott, 1986], [Bell, 1988], [McLarty, 1992], [Mac Lane and Mo-
erdijk, 1992]. None of these are aimed at applications to computer science.
We do not discuss the language and logic corresponding to a topos in this
book. The most accessible introduction to this is perhaps that of [McLarty,
1992], Chapter 16. Other discussions of the language and the relation with
logic are in [Makkai and Reyes, 1977], [Fourman, 1977], [Fourman and Vick-
ers, 1986], [Boileau and Joyal, 1981]. The texts [Makkai and Reyes, 1977]
and [Freyd and Scedrov, 1990] discuss toposes and also more general classes
of categories that have a rich logical structure. The use of toposes speciﬁ-
cally for semantics is discussed in [Hyland, 1982], [Hyland and Pitts, 1989],
[Vickers, 1992].

15.1 Deﬁnition of topos

15.1.1 The subobject functor Recall from 2.8.11 that if C is an object
of a category, a subobject of C is an equivalence class of monomorphisms C0
(cid:41)−→ C where f0 : C0 (cid:41)−→ C is equivalent to f1 : C1 (cid:41)−→ C if and only if there
are arrows (necessarily isomorphisms) g : C0 −→ C1 and h : C1 −→ C0 such
that f1 ◦ g = f0 and f0 ◦ h = f1.

Assuming the ambient category C has pullbacks, the ‘set of subobjects’
function is the object function of a functor Sub : C op −→ Set: precisely, for
an object C, Sub(C) is the set of subobjects of C. We must deﬁne Sub on
arrows.

If k : C(cid:48) −→ C is an arrow and if f0 : C0 (cid:41)−→ C represents a subobject of

C, then in a pullback

C(cid:48)
0
(cid:63)

C0(cid:45)k0
(cid:63)

f (cid:48)
0

(cid:63)
C(cid:48)

f0
(cid:63)
C(cid:45)

k

(15.1)

the arrow f (cid:48)

0 is also a monomorphism (see 9.3.4).

15.1 Deﬁnition of topos

385

It is left as an exercise to prove, using the universal mapping property of
pullbacks, that if the monomorphism f0 : C0 (cid:41)−→ C is equivalent to f1 : C1
1 (cid:41)−→ C(cid:48) are also equiva-
(cid:41)−→ C, then the pullbacks f (cid:48)
lent. Thus not only is a pullback of a monomorphism a monomorphism, but
also a pullback of a subobject is a subobject.

0 (cid:41)−→ C(cid:48) and f (cid:48)

0 : C(cid:48)

1 : C(cid:48)

Thus we can deﬁne, for an arrow k as above,

Sub(k) : Sub(C) −→ Sub(C(cid:48))

to be the function that sends the equivalence class containing f0 to the
equivalence class containing the pullback f (cid:48)
0.

To show that this is a functor, we must show that the identity arrow
induces the identity arrow on subobjects (exercise) and that if k(cid:48) : C(cid:48)(cid:48) −→ C(cid:48),
then the diagram

Sub(C)
(cid:64)

(cid:45)Sub(k)

Sub(C(cid:48))

(cid:64)

(cid:64)
Sub(k ◦ k(cid:48))

(cid:64)

Sub(k(cid:48))

(cid:64)

(cid:64)
(cid:63)
(cid:64)(cid:82)
Sub(C(cid:48)(cid:48))

commutes. But the commutativity of this diagram at the subobject repre-
sented by f0 is equivalent to the outer rectangle of the diagram

(cid:45) k(cid:48)

0

C(cid:48)(cid:48)
0

(cid:45)

(cid:45) k0
C(cid:48)
0

C0(cid:45)

f (cid:48)(cid:48)
0

(cid:63)
(cid:45)
C(cid:48)(cid:48)

f (cid:48)
0
(cid:63)
(cid:45)
C(cid:48)(cid:45)

k(cid:48)

f0
(cid:63)
C(cid:45)

k

being a pullback when the two smaller squares are, which is true by Exer-
cise 10 of Section 9.3.

15.1.2 Deﬁnition A topos is a category which

TOP–1 has ﬁnite limits;
TOP–2 is cartesian closed;

386

Toposes

TOP–3 has a representable subobject functor.

We know that a functor is representable if and only if it has a universal
element (see 4.5.9). A universal element of the subobject functor is an object,
usually called Ω, and a subobject Ω0 ⊆ Ω such that for any object A and
subobject A0 ⊆ A, there is a unique arrow χ : A −→ Ω such that there is a
pullback

(cid:45)

A0

A(cid:45)

χ

(cid:63)

Ω(cid:45)

(cid:63)
(cid:45)
Ω0

It can be proved that Ω0 is the terminal object and the left arrow is the
unique arrow from A0 ([Barr and Wells, 1985], Proposition 4 of Section 2.3).
The object Ω is called the subobject classiﬁer and the arrow from Ω0 =
1 −→ Ω is usually denoted true. The arrow χ corresponding to a subobject
is called the characteristic arrow of the subobject.

The fact that the subobject functor is represented by Ω means precisely

that there is a natural isomorphism

φ : Sub(−) −→ Hom(−, Ω)

which takes a subobject to its characteristic function.

15.1.3 Example The category of sets is a topos. It was shown in 6.1.9
that sets are a cartesian closed category. A two-element set, which we call
2, is a subobject classiﬁer. In fact, call the two elements true and false.
Given a set S and subset S0 ⊆ S, deﬁne the characteristic function χ : S
−→ {true, false} by

(cid:189)

χ(x) =

true
false

if x ∈ S0
if x /∈ S0

Then the following square (where the top arrow is inclusion) is a pullback:

(cid:45)

S0

(cid:63)
1

S(cid:45)

χ

(cid:63)

2(cid:45)

true

Thus 2 is a subobject classiﬁer.

15.1.4 Exercises

15.2 Properties of toposes

387

1. Referring to Diagram (15.1), show that if the monomorphism f0 : C0
(cid:41)−→ C is equivalent to f1 : C1 (cid:41)−→ C, then for any g : C(cid:48) −→ C, the pullbacks
1 (cid:41)−→ C(cid:48) are also equivalent.
0 : C(cid:48)
f (cid:48)
2. Show that the identity arrow C −→ C induces the identity arrow Sub(C)
−→ Sub(C).

0 (cid:41)−→ C(cid:48) and f (cid:48)

1 : C(cid:48)

3. Show that the category of ﬁnite sets and all functions between them is a
topos.
4.† (Requires some knowledge of inﬁnite cardinals.) Show that the category
of ﬁnite and countably inﬁnite sets and all functions between them has a
subobject classiﬁer but is not cartesian closed. (Hint: the set of subsets of a
countable set is not countable.)

15.2 Properties of toposes

We list here some of the properties of toposes, without proof.

15.2.1 In the ﬁrst place, a topos is not only cartesian closed, it is locally
cartesian closed (see Section 13.4). This is Corollary 1.43, p. 36 of [John-
stone, 1977], Corollary 7, p. 182 of [Barr and Wells, 1985] or section 17.2 of
[McLarty, 1992].

15.2.2 Power objects
that

In any topos, the object [A −→ Ω] has the property

Hom(B, [A −→ Ω]) ∼= Hom(A × B, Ω) ∼= Sub(A × B)

(15.2)

These isomorphisms are natural when the functors are regarded as functors
of either A or of B. (One of them appears, for Set, in Example 4.3.7.) The
object [A −→ Ω] is often called the power object of A and denoted PA. It
is the topos theoretic version of the powerset of a set. Theorem 1 of Section
5.4 of [Barr and Wells, 1985] implies that a category with ﬁnite limits is a
topos if for each object A there is a power object that satisﬁes (15.2).

The inverse image and universal image constructions in 13.2.7 for the
powerset of a set can be made on [A −→ Ω] for any object A in a topos.
The left and right adjoints of the pullback functors (they exist because any
topos is locally cartesian closed) are related to these images via the diagram
in [Johnstone, 1977], Proposition 5.29; this diagram is called the ‘doctrinal
diagram’ and is the basis for introducing elementary (ﬁrst order) logic into
a topos.

388

Toposes

15.2.3 Eﬀective equivalence relations Let d, e : E −→−→ A be two arrows
in a category. For any object B we have a single function

(cid:104)Hom(B, d), Hom(B, e)(cid:105) : Hom(B, E) −→ Hom(B, A) × Hom(B, A)

which sends f to the pair (d ◦ f, e ◦ f ). If this function is, for each object
B, an isomorphism of Hom(B, E) with an equivalence relation on the set
Hom(B, A), then we say that E is an equivalence relation on the object A.
This means that the image of (cid:104)Hom(B, d), Hom(B, e)(cid:105) is actually an equiva-
lence relation on Hom(B, A).

This can be thought of as embodying two separate conditions. First, the
function (cid:104)Hom(B, d), Hom(B, e)(cid:105) must be an injection, because we are sup-
posing that it maps Hom(B, E) isomorphically to a subset of Hom(B, A) ×
Hom(B, A). Secondly, that subset must satisfy the usual reﬂexivity, symme-
try and transitivity conditions of equivalence relations.

15.2.4 Kernel pairs Here is one case in which this condition is auto-
matic. If g : A −→ C is an arrow, the pullback of the square

E

e

A(cid:45)d

g

(cid:63)
A

(cid:63)

C(cid:45)

g

is called a kernel pair of g. Notation: we will write that

E

d
−−→−−→
e

g

−−→ C

A

is a kernel pair. For an object B of C , the deﬁnition of this limit is that there
is a one to one correspondence between arrows B −→ E and pairs of arrows
(h, k) from B to A such that g ◦ h = g ◦ k and that the correspondence is
got by composing an arrow from B to E with d and e, resp. To put it in
other words, Hom(B, E) is isomorphic to

{(h, k) ∈ Hom(B, A) × Hom(B, A) | g ◦ h = g ◦ k}

which is an equivalence relation.

15.2.5 Suppose that E −→−→ A describes an equivalence relation. We say
that the equivalence relation is eﬀective if it is a kernel pair of some arrow
from A. We say that a category has eﬀective equivalence relations if
every equivalence relation is eﬀective. We give the following without proof.
The interested reader may ﬁnd the proof in [Barr and Wells, 1985] Theo-
rem 7 of Section 2.3, [Johnstone, 1977], Proposition 1.23, p. 27, or [McLarty,
1992], Section 16.7.

15.2 Properties of toposes

389

15.2.6 Theorem In a topos, every equivalence relation is eﬀective.

15.2.7 Example Equivalence relations in the categories Set and Mon
are eﬀective. An equivalence relation in Set is simply an equivalence re-
lation, and the class map to the quotient set is a function that has the
equivalence relation as kernel pair. An equivalence relation on a monoid M
in Mon is a congruence relation on M (see Exercise 6 of Section 3.5); it is
eﬀective because a monoid multiplication can be deﬁned on the quotient set
of the congruence relation that makes the quotient map a homomorphism
(Exercise 3).

There are many categories which lack eﬀective equivalence relations. One
is the category of partially ordered sets and monotone maps. Here is a simple
example. Let C be a two-element chain x < y. Consider the subset E of C ×C
consisting of all four pairs (x, x), (x, y), (y, x) and (y, y). The only ordering is
that (x, x) ≤ (y, y). Then E is an equivalence relation, but is not the kernel
pair of any arrow out of C. The least kernel pair that includes E has the
same elements as E, but has the additional orderings (x, x) ≤ (x, y) ≤ (y, y)
and (x, x) ≤ (y, x) ≤ (y, y).

Other important properties of toposes are contained in the following.

15.2.8 Theorem Let E be a topos.

(a) E has ﬁnite colimits.
(b) E has ﬁnite disjoint and universal sums.
(c) Every epi in E is regular, and E is a regular category.

An early proof of the fact that a topos has ﬁnite colimits ([Mikkelson, 1976])
mimicked the construction in sets. For example, the coequalizer of two arrows
was constructed as a set of subsets, which can be identiﬁed as the set of equiva-
lence classes mod the equivalence relation generated by the two arrows. How-
ever, the argument is diﬃcult. The modern proof (due to Par´e) is much easier,
but it involves some legerdemain with triples and it is hard to see what it is
actually doing. See [Barr and Wells, 1985], Corollary 2 of 5.1 for the latter
proof. The rest is found in 5.5 of the same source.

15.2.9 The initial topos There is an FL sketch whose models are to-
poses. (See [Barr and Wells, 1985], Section 4.4. In that book, FL sketches
are called LE sketches.) It follows that there is an initial model of the topos
axioms. This topos lacks a natural numbers object. It might be an interest-
ing model for a rigidly ﬁnitistic model of computation, but would not allow
the modeling of such things as recursion.

The phrase ‘initial topos’ is usually reserved for the initial model of the
axioms for toposes with a natural numbers object (Section 5.5). This cate-
gory provides an interesting model for computation. The arrows from N to N

390

Toposes

in that category are, not surprisingly, the total recursive functions. In fact,
all partial recursive functions are modeled in there as well, but as partial
arrows, which we now describe.

15.2.10 Partial arrows
In 2.1.13 we discussed partial functions between
sets. This concept can be extended to any category. Let A and B be objects.
A partial arrow A to B consists of a subobject A0 ⊆ A and an arrow f : A0
−→ B. This deﬁnes the partial arrow f in terms of a particular representative
A0 −→ A of the subobject, but given any other representative A(cid:48)
0 −→ A,
there is a unique arrow from A(cid:48)
0 to A0 commuting with the inclusions which
determines an arrow from A(cid:48)
0 to B by composition with f . The subobject
determined by A0 is called the domain of the partial arrow. If g : A1 −→ B
is another partial arrow on A we say the f ≤ g if A0 ⊆ A1 and the restriction
of g to A0 is f . If we let i : A0 −→ A1 denote the inclusion arrow, then the
second condition means simply that g ◦ i = f . We will say that f and g
are the same partial arrow if both f ≤ g and g ≤ f . This means that the
domains of f and g are the same subobject of A and that f and g are equal
on that domain.

We say that partial arrows to B are representable if there is an
object (cid:101)B and an embedding B (cid:41)−→ (cid:101)B such that there is a one to one cor-
respondence between arrows A −→ (cid:101)B and partial arrows A to B, the corre-
spondence given by pulling back:

A0

A(cid:45)

(cid:63)
B

(cid:63)
(cid:101)B(cid:45)

In a topos, the arrow true: 1 −→ Ω represents partial functions to 1. The
reason is that since each object has a unique arrow to 1, a partial arrow
from A to 1 is equivalent to a subobject of A.

15.2.11 Theorem In a topos, partial arrows into any object are repre-
sentable.

See [Johnstone, 1977], Section 1.26 or [McLarty, 1992], Section 17.1 for

the proof.

15.3 Is a two-element poset complete?

391

15.2.12 Exercises

1. Verify the isomorphisms of (15.2) for Set.

2. Let S be a set and E be an equivalence relation on S. Then there are
two arrows E to S, being the inclusion of E into S × S, followed by the two
projections on S. Show that E, together with these two arrows, is the kernel
pair of the function that takes each element of S to the equivalence class
containing it.
3. a. Let d, e : E −→−→ M be two monoid homomorphisms. Show that they
form an equivalence relation in Mon if and only if the arrow

(cid:104)d, e(cid:105)

−−−−−→ M × M

E

is a monomorphism and the image of (cid:104)d, e(cid:105) is a congruence on M (see Exer-
cise 6 of Section 3.5 with d, e the projections).

b. Show that equivalence relations in Mon are eﬀective.

4. Show that in any category with kernel pairs, if f : C −→ D is a coequalizer,
then it is the coequalizer of its kernel pair.

5. Give an example in Set of a function with a kernel pair which is not the
coequalizer of its kernel pair.
6. Show that in the category of sets, (cid:101)S can be taken to be S ∪ {∗}, where ∗
is an element not in S.
7. Show that in a topos, the subobject classiﬁer is (cid:101)1, the object that repre-
sents partial arrows into 1.

15.3 Is a two-element poset complete?

This discussion requires familiarity with the concept of recursive set (there
is an algorithm that always halts that tells whether an element is in the set
or not) and recursively enumerable set (there is an algorithm that generates
all the elements of the set and no others).

We consider a 2 element chain we denote by 2. The word ‘complete’ in the
question in the heading means that it has sups of all subsets. The question
seems absurd at ﬁrst, but it improves with age. In fact, we will show that
both in a topos and in realistic models of computation, the answer is ‘no’.
Moreover the answer is no in both cases for the same reason.

The claim we want to make, and for which this discussion is evidence, is
that topos semantics is an appropriate model for computation, or at least a
more appropriate one than set theory. This will not mean that topos theory
will tell you how to compute something that you could not compute without

392

Toposes

it. What happens is that in many toposes certain computationally meaning-
less constructions cannot be made at all, although they are all possible in
Set.

15.3.1 Computation models Of course, in a most naive sense, 2 is cer-
tainly complete as a poset, but we want to look at this in a more sophisticated
way. What we really want to be true if we say that a poset P is complete is
that for any other object A, the poset [A −→ P ], with the pointwise order,
is complete. In the case of 2, this means that [A −→ 2] is complete. To see
why we want this to be true, recall that an element of a set is essentially
the same thing as a function from a one-element set to that set. However, in
categories thought of as workspaces, it is more useful to think of any arrow
with codomain S as an element of S – a variable element of S. (A variable
elements whose domain is a terminal object is then a constant element or
global element (2.7.19)). Categories rich enough to be workspaces for a type
of mathematics typically come with an internal language; statements in
that internal language can often be perceived as statements about elements,
but their truth is dependent on ‘elements’ being interpreted as variable ele-
ments.

In the case of ordinary set theory, it is still true that 2 is complete in
this internal sense. For computational semantics, the situation is diﬀerent.
Consider the case A = N, although any inﬁnite set would do as well. A
function N −→ 2 is determined by and determines a subset of N. However,
a computable function N −→ 2 is determined by and determines a recursive
subset of N. And it is well known that the set of recursive subsets of N
is not complete. It is not even countably complete; in fact, the recursively
enumerable subsets are characterized as the countable unions of recursive
subsets. Of course, arbitrary unions of recursive subsets will be even worse.

15.3.2 Topos models The situation in an arbitrary topos is similar. A
topos has an object Ω with the property that for any object A, Hom(A, Ω)
is the set of subobjects of A. A topos also always has an object 2 = 1 + 1,
and an arrow A −→ 2 does not represent an arbitrary subobject, but rather
a complemented subobject (see 9.6.2). Such an arrow A −→ 2 gives a decom-
position of A as a sum A0 + A1 where A0 and A1 are the pullbacks shown
below, where true, false : 1 −→ 2 are the two injections:

A0

A(cid:45)

A1

A(cid:45)

(cid:63)
1

(cid:63)

2(cid:45)

false

(cid:63)
1

(cid:63)

2(cid:45)

true

15.4 Presheaves

393

The fact that a topos has universal sums implies that from 2 = 1 + 1 we
can conclude that A = A0 + A1. On the other hand, if A = A0 + A1, there
is a unique arrow A −→ 2 whose restriction to A0 is false ◦ (cid:104)(cid:105) and to A1 is
true ◦ (cid:104)(cid:105). Thus 2 is internally complete in a topos if and only if the supremum
of complemented sets are complemented. It is not hard to show that this
is not true in general. In fact, there is a topos in which the arrows from
N to 2 are just the total recursive two-valued functions (and in fact, the
arrows from N to itself are also the total recursive functions). In that topos
a complemented subset of N is exactly a recursive subset (one which, with
its complement, has a recursive characteristic function) and the fact that a
union of recursive subsets is not necessarily recursive ﬁnishes the argument.
In 6.6.4 we constructed a semantics for an If loop by constructing a
supremum in [A −→ D⊥], where D⊥ is a ﬂat CPO (of which 2 is an example).
However, the last paragraph shows that in general this semantics does not
make computational sense. The reason is that, although you can write down
the sup as a formal thing, it will not be guaranteed to give a terminating
program. The sup of partial functions exists, but the domain of such a partial
function is not generally computable.

In a topos model of computational semantics, in which all arrows N
−→ N are given by recursive functions, a subobject of N is determined by
an arrow into Ω. The maps into Ω cannot usually be computed. The one
special case in which they can is that of an arrow that factors through the
subobject (cid:104)true; false(cid:105) : 2 −→ Ω. This corresponds to the traditional distinc-
tion between recursively enumerable and recursive subsets. In classical set
theory, all subsets are classiﬁed by arrows into 2, but here only recursive
subsets are.

15.4 Presheaves

15.4.1 Deﬁnition Let C be a category. A functor E : C op −→ Set is
called a presheaf on C . Thus a presheaf on C is a contravariant func-
tor. The presheaves on C with natural transformations as arrows forms a
category denoted Psh(C ).

We considered presheaves as actions in Section 3.2. They occur in other
guises in the categorical and computer science literature, too. For example,
a functor F : A −→ Set, where A is a set treated as a discrete category, is
a ‘bag’ of elements of A. If a ∈ A, the set F (a) denotes the multiplicity
to which a occurs in A. See [Taylor, 1989] for an application in computing
science.

15.4.2 Proposition The category of presheaves on a category C form a
topos.

394

Toposes

The proof may be found in [Barr and Wells, 1985] Section 2.1, Theorem

4. That proof uses a diﬀerent, but equivalent, deﬁnition of topos.

15.4.3 Example Consider the category we will denote by 0 −→−→ 1. It has
two objects and four arrows, two being the identities. A contravariant set-
valued functor on this category is a pair of objects G0 and G1 and a pair of
arrows we will call source, target : G1 −→ G0. The two identities are sent to
identities. Thus the category of presheaves on this category is the category
of graphs, which is thereby a topos. This category is the theory of the sketch
for graphs given in 4.6.7.

We described the exponential object for graphs in 6.1.12. It is instructive
to see what the subobject classiﬁer is. We have to ﬁnd a graph Ω and an
arrow true : 1 −→ Ω such that for any graph G and subgraph G0 ⊆ G , there
is a unique graph homomorphism χ : G −→ Ω such that the diagram

(cid:45)

G0

G(cid:45)

χ

(cid:63)
Ω(cid:45)

(cid:63)
1

true

commutes.

We deﬁne the graph Ω as follows. It has ﬁve arrows we will call ‘all’,
‘source’, ‘target’, ‘both’ and ‘neither’. The reason for these names should
become clear shortly. It has two nodes we will call ‘in’ and ‘out’. The arrows
‘all’ and ‘both’ go from ‘in’ to itself, ‘neither’ goes from ‘out’ to itself. The
arrow ‘source’ goes from ‘in’ to ‘out’ and ‘target’ from ‘out’ to ‘in’. The
terminal graph, which has one arrow and one node, is embedded by the
function true that takes the arrow to ‘all’ and the node to ‘in’.

Now given a graph G and a subgraph G0 we deﬁne a function χ : G −→ Ω
as follows. For a node n of G , χ(n) is ‘in’ or ‘out’, according to whether n is
in G0 or not. For an arrow a, we let χ(a) be ‘all’ if a ∈ G0 (whence its source
and target are as well). If not, there are several possibilities. If the source
but not the target of a belongs to G0, then χ(a) =‘source’. Similarly, if the
target but not the source is in G0, it goes to ‘target’. If both the source and
target are in it, then χ(a) =‘both’ and if neither is, then it goes to ‘neither’.

15.5 Sheaves

395

15.4.4 Exercises

1. Show that the graphs No and Ar discussed in 6.1.12 are actually the
contravariant set-valued functors on 0 −→−→ 1 represented by the objects 0 and
1, respectively.

2. Show that the object Ω in the category of graphs can be described as
follows. The nodes are the subgraphs of No and the arrows are the subgraphs
of Ar and the source and target are induced by s and t (deﬁned in 6.1.12),
respectively.

3. Let C be a category, and let M and N be two objects of Psh(C ). Use
the Yoneda Lemma and the adjunction deﬁning cartesian closed categories
to show that for any object X of C , [M −→ N ](X) must be the set of natural
transformations from Hom(−, X) × M to N , up to isomorphism. Note that
this does not prove that Psh(C ) is cartesian closed. That is true, but requires
ideas not given here (see [Mac Lane and Moerdijk, 1992], page 46).

4. Let C be a category and X an object of C . Let Ω be the subobject classi-
ﬁer of Psh(C ). Show that Ω(X) is, up to isomorphism, the set of subfunctors
(see Exercise 3 of Section 4.3) of Hom(−, X).

15.5 Sheaves

The general deﬁnition of sheaves requires a structure on the category called
a Grothendieck topology. The most accessible and detailed discussion of
Grothendieck topologies is that of [Mac Lane and Moerdijk, 1992]. Here we
will discuss the special case of sheaves in which the category is a partial
order.

15.5.1 Let P be a partially ordered set. From the preceding section, a
presheaf E on P assigns to each element x ∈ P a set E(x) and whenever
x ≤ y assigns a function we will denote E(x, y) : E(y) −→ E(x) (note the
order; x precedes y, but the arrow is from E(y) to E(x)). This is subject
to two conditions. First, that E(x, x) be the identity function on E(x) and
second that when x ≤ y ≤ z, that E(x, y) ◦ E(y, z) = E(x, z). The arrows
E(x, y) are called restriction functions.

15.5.2 Heyting algebras We make the following supposition about P .

HA–1 There is a top element, denoted 1, in P .
HA–2 Each pair of elements x, y ∈ P has an inﬁmum, denoted x ∧ y.
(cid:87)
HA–3 Every subset {xi} of elements of P has a supremum, denoted

xi.

396

Toposes

(cid:87)

(x ∧ xi).

HA–4 For every element x ∈ P and every subset {xi} ⊆ P , x ∧ (

xi) =

(cid:87)

A poset that satisﬁes these conditions is called a complete Heyting

algebra.

15.5.3 If {xi} is a subset with supremum x, and E is a presheaf, there
is given a restriction function ei : E(x) −→ E(xi) for each i. The universal
property of product gives a unique function e : E(x) −→
i E(xi) such that
pi ◦ e = ei. In addition, for each pair of indices i and j, there are functions cij :
E(xi) −→ E(xi ∧ xj) and dij : E(xj) −→ E(xi ∧ xj) induced by the relations
i E(xi) −→
xi ≥ xi ∧ xj and xj ≥ xi ∧ xj. This gives two functions c, d :
(cid:81)

(cid:81)

(cid:81)

ij E(xi ∧ xj) such that

(cid:81)

i E(xi)

(cid:45)c

(cid:81)

ij E(xi ∧ xj)

pi

(cid:63)
E(xi)

pij

(cid:45)

(cid:63)
E(xi ∧ xj)

cij

(cid:81)

i E(xi)

(cid:45)d

(cid:81)

ij E(xi ∧ xj)

pi

(cid:63)
E(xi)

pij

(cid:45)

(cid:63)
E(xi ∧ xj)

dij

and

commute.

15.5.4 Deﬁnition A presheaf is called a sheaf if it satisﬁes the following
additional condition:

(cid:95)

x =

xi

implies

is an equalizer.

E(x)

e
−→

(cid:89)

i

E(xi)

c
−−→−−→
d

(cid:89)

ij

E(xi ∧ xj)

15.5.5 Theorem The category of sheaves on a Heyting algebra is a topos.

As a matter of fact, the category of sheaves for any Grothendieck topology
is a topos (see any of the texts [Johnstone, 1977], [Barr and Wells, 1985],
[Mac Lane and Moerdijk, 1992], [McLarty, 1992]).

15.5 Sheaves

397

15.5.6 Constant sheaves A presheaf E is called constant if for all x ∈
P , E(x) is always the same set and for all x ≤ y, the function E(y, x) is the
identity function on that set.

The constant presheaf at a one-element set is always a sheaf. This is

because the sheaf condition comes down to a diagram

1 −→ 1 −→−→ 1

which is certainly an equalizer. No constant presheaf whose value is a set
with other than one element can be a sheaf. In fact, the 0 (bottom) element
of P is the supremum of the empty set and the product of the empty set of
sets is a one-element set (see 5.3.6). Hence the sheaf condition on a presheaf
E is that

E(0) −→

(cid:89)

(cid:89)

−→−→

which is

∅

∅

E(0) −→ 1 −→−→ 1

and this is an equalizer if and only if E(0) = 1.

15.5.7 A presheaf is said to be nearly constant if whenever 0 < x ≤ y
in P , the restriction E(y) −→ E(x) is an isomorphism. It is interesting to
inquire when a nearly constant presheaf is a sheaf. It turns out that every
nearly constant presheaf over P is a sheaf over P if and only if the meet of
two nonzero elements of P is nonzero.

To see this, suppose E is a nearly constant presheaf whose value at any

x (cid:54)= 0 is S and that x =

(cid:87)

xi. In the diagram
(cid:89)

(cid:89)

E(xi) −→−→

E(x) −→

E(xi ∧ xj)

every term in which xi = 0 contributes nothing to the product since 1 × Y ∼=
Y . An element of the product is a string {si} such that si ∈ S. The condition
of being an element of the equalizer is the condition that the image of si
under the induced function E(xi) −→ E(xi ∧ xj) is the same as the image
of sj under E(xj) −→ E(xi ∧ xj). But in a nearly constant sheaf, all these
sets are the same and all the functions are the identity, so this condition is
simply that si = sj. But this means that an element of the equalizer must
be the same in every coordinate, hence that diagram is an equalizer.

15.5.8 Interpretation of sheaves Let E be a sheaf on P . The reader
will want to know how E is to be interpreted. Start by thinking of P as an
algebra of truth values. Whereas propositions (assertions) in ordinary logic
are either true or false (so that ordinary logic is often called 2-valued), in

398

Toposes

P -valued logic, the truth of an assertion is an element of P . In the next
section, we will use this idea to discuss time sheaves in which propositions
can be true at some times and not at others. If p is some proposition, let us
write [[p]] to denote the element of P that is the truth value.

A sheaf E is a set in this logic. For x ∈ P , the (ordinary) set E(x) could,
as a ﬁrst approximation, be thought of as the set of all entities a for which
[[a ∈ E]] is at least x. If y < x, then [[a ∈ E]] ≥ x implies that [[a ∈ E]] ≥ y
so that E(x) ⊆ E(y). This is only a ﬁrst approximation and what we have
described is actually a P -valued fuzzy set (see 15.6). The reason is that
equality is also a predicate and it may happen, for example, that [[a = b]]
could lie between x and y so that the entities a and b are not discernably
equal at level x, but are equal at level y. The result is that rather than an
inclusion, we have a restriction function E(x) −→ E(y) for y ≤ x.

15.5.9 Time sheaves, I Here is a good example of a topos in which one
can see that the restriction arrows should not be expected to be injective.
Consider the partially ordered set whose elements are intervals on the real
line with inclusion as ordering. It is helpful to think of these as time intervals.
Now consider any deﬁnition of a naive set. Some possible deﬁnitions will
be time invariant, such as the set of mathematical statements about, say,
natural numbers, that are true. Others of these ‘sets’ change with time; one
example might be the set of all books that are currently in print; another
the set of statements currently known to be true about the natural numbers.
These may conveniently be thought of as the presheaves whose value on some
time interval is the set of books that were in print over the entire interval
and the set of statements about natural numbers known to be true during
that entire interval. The restriction to a subinterval is simply the inclusion
of the set of books in print over the whole interval to that (larger) set of
those in print over that subinterval or the restriction of the knowledge from
the interval to the subinterval. In this example, the restrictions are injective.
Instead of books in print, we could take the example of businesses in
operation. Because of the possibility of merger, divestment and the like, two
businesses which are actually distinct over a large interval might coincide
over a smaller subinterval. Thus for this example of a “set”, the restriction
function is not injective in general.

Another situation in which the restriction functions are not necessarily
injective arises from the set of variables in a block-structured programming
language. The presheaf is this: the set for a certain time interval during the
running of the program is the quotient of the set of variables which exist
over the whole time interval, modulo the equivalence relation that identiﬁes
two variables in an interval if they should happen to have the same value
over the whole interval. Two variables may not be equivalent over a large

15.5 Sheaves

399

interval, whereas they may be equivalent over a smaller one; in that case the
restriction function would not be injective.

In general, any property describes the set of all entities that have that
property over the entire interval. The restriction to a subinterval arises out
of the observation that any entity that possesses a property over an interval
possesses it over any subinterval.

The sheaf condition in this case reduces to this: if the interval I is a
union of subintervals Ik (where k ranges over an index set which need not
be countable) and an entity possesses that property over every one of the
subintervals Ik, then it does over the whole interval. This condition puts a
deﬁnite restriction on the kinds of properties that can be used. For example,
the property of being grue, that is blue over the ﬁrst half of the interval
and green on the second half, is not allowed. The properties that are allowed
are what might be called local, that is true when they are true in each
suﬃciently small interval surrounding the point in time. This statement is
essentially a tautology, but it does give an idea of what the sheaf condition
means.

15.5.10 Time sheaves, II Here is another topos, rather diﬀerent from
the one above, that might also be considered to be time sheaves. Unlike the
one above which is symmetric to forward and reverse time, this one deﬁnitely
depends on which way time is ﬂowing. This is not to say that one is better
or worse, but they are diﬀerent and have diﬀerent purposes. In this one, the
elements of the Heyting algebra are the times themselves. In other words,
we are looking at time indexed sets, as opposed to sets indexed by time
intervals.

We order this set by the reverse of the usual order. So a presheaf in this
model is a family {X(t)} of sets, t a real number, together with functions
f (s, t) : X(t) −→ X(s) for t ≤ s, subject to the condition that f (t, t) is the
identity and f (r, s) ◦ f (s, t) = f (r, t) for t ≤ s ≤ r. The sheaf condition of
Deﬁnition 15.5.4 is a bit technical, but can easily be understood in the special
case of a presheaf all of whose transition arrows f (s, t) are inclusions. In that
case, the condition is that when t =
ti (so that t is the greatest lower bound
of the ti), then X(t) =

X(ti).

(cid:86)

(cid:84)

An example, which might be thought typical, of such a sheaf might be
described as the ‘sheaf of states of knowledge’. At each time t we let X(t)
denote the set of all things known to the human race. On the hypothesis
(which might be disputed) that knowledge is not lost, we have a function
X(t) −→ X(s) for t ≤ s. In common parlance, we might consider this function
to be an inclusion, or at least injective, but it is possible to modify it in
various ways that will render it not so. We might introduce an equivalence
relation on knowledge, so that two bits of knowledge might be considered the

400

Toposes

same. In that case, if at some future time we discover two bits of knowledge
the same, then bits not equal at one time become equal at a later time and
the transition arrow is not injective.

For example, consider our knowledge of the set of complex numbers.
There was a time in our history when all the numbers e, i, π and −1 were
all known, but it was not known that eiπ = −1. In that case, the number eiπ
and −1 were known separately, but not the fact that they were equal. See
[Barr, McLarty and Wells, 1985]. The sheaf condition is this: if {ti} is a set
of times and t is their inﬁmum, then anything known at time ti for every i
is known at time t.

15.5.11 Exercise

1. Let H be a complete Heyting algebra. Deﬁne the binary operation ⇒:
Hsc × Hsc −→ Hsc by requiring that a ⇒ b is the join of all elements c for
which a ∧ c ≤ b.

a. Prove that a ∧ c ≤ b if and only if c ≤ a ⇒ b.
b. Prove that when H is regarded as a category in the usual way, it is

cartesian closed with ⇒ as internal hom.

15.6 Fuzzy sets

Fuzzy set theory is a more-or-less categorical idea that some claim has ap-
plication to computer modeling. It appears to be closely related to topos
theory. In fact, it appears to us that the interesting core of the subject is
already implicit in topos theory. We will not go deeply into the subject, but
only give a few deﬁnitions and point out the connections. More details can
be found in [Barr, 1986a], [Pitts, 1982].

15.6.1 At this point, it would be appropriate to give some deﬁnitions. One
of the problems with fuzzy sets is that the meaning of the term has been
left vague (one might say fuzzy). Rather than attempt to give all possible
deﬁnitions, we content ourselves with a deﬁnition that is common and for
which the connection with topos theory is as simple as possible.

15.6.2 Deﬁnition Let P be a complete Heyting algebra. A P -valued set
is a pair (S, σ) consisting of a set S and a function σ : S −→ P . A category
of fuzzy sets is the category of P -valued sets (in other words, the slice
category Set /P ) for a ﬁxed complete Heyting algebra P .

In practice, fuzzy sets are deﬁned with P being the closed interval of real
numbers from 0 to 1, which is a complete Heyting algebra with the usual
ordering. Think of σ(s) as being the degree of membership of s in the fuzzy

15.6 Fuzzy sets

401

set. If σ(s) = 1, then s is fully in the fuzzy set, while if σ(s) = 0, then s is
not in the fuzzy set at all.

Actually that last statement is not quite true; we will return to this point later;
pretend for the moment that it is.

15.6.3 Let (S, σ) and (T, τ ) be fuzzy sets. An arrow f : (S, σ) −→ (T, τ ) is
an arrow f : S −→ T such that σ ≤ τ ◦ f . Thus the degree of membership of
s in (S, σ) cannot exceed that of f (s) in (T, τ ). With this deﬁnition and the
obvious identity arrows, the fuzzy sets based on P form a category Fuzz(P ).

The hypothesis actually made on P was that both P and the opposite order
P op were Heyting algebras ([Goguen, 1974]). The hypothesis on P op plays no
role in the theory and so we have omitted it.

15.6.4 Once we have deﬁned the category of fuzzy sets, the deﬁnition of
subset of a fuzzy set emerges. For f : (S, σ) (cid:41)−→ (T, τ ) to be monic it is
necessary that f be injective. In particular, we can think of a subset of
(T, τ ) as being a fuzzy set (T0, τ0) where T0 ⊆ T and τ |T0 ≤ τ0.

15.6.5 More ado about nothing Consider the following two fuzzy sub-
sets of (S, σ). The ﬁrst is the set (∅, (cid:104)(cid:105)) and the second is the set (S, 0) where
(cid:104)(cid:105) is the unique function of ∅ to P and 0 stands for the function that is
constantly zero. One is the empty set and the other is the set in which every
element is not there. There is seemingly no diﬀerence between these two sets
as neither actually contains any elements. In fact, in fuzzy set theory, these
two sets (and sets in between) are not considered to be equal. This results
in the class of fuzzy set theories being curiously restricted (see 15.6.10).

15.6.6 Fuzzy sets and sheaves The reader may suspect (from the title
of this section, if nothing else) that there is a connection between fuzzy sets
and toposes. Both are generalizations of set theory to introduce lattices more
general than the two-element lattice as truth values.

One of the two diﬀerences has just been mentioned; the diﬀerent treat-
ment of the null set. Actually, this diﬀerence is relatively minor. The second
one is not. Suppose (S, σ) is a fuzzy set. We can deﬁne a presheaf E by
letting

E(x) = {s ∈ S | σ(s) ≥ x}

as suggested in our informal discussion. Clearly, if y ≤ x, then E(x) ⊆ E(y)
and using these inclusions, we get a presheaf on P . It is almost never a sheaf,
however. The essential reason for this is that E(0) = S, while we have seen
in 15.5.6 that E(0) = 1 when E is a sheaf.

402

Toposes

15.6.7 It turns out there is a very simple way to make E into a sheaf,
but not on P . Let P + denote the poset constructed from P by adding a new
bottom element. Let us call the new bottom element ⊥ to distinguish it from
the old one we called 0. Now given a P indexed fuzzy set, deﬁne a presheaf
on P + by letting E(x) be deﬁned as above for x ∈ P and E(⊥) = 1.

15.6.8 Proposition The presheaf E just deﬁned is a sheaf. It is a sub-
sheaf of the near constant sheaf C deﬁned by C(x) = S for x (cid:54)= ⊥ and
C(⊥) = 1.

Proof. We ﬁrst observe that P + obviously has the property that the meet
of two nonzero elements is nonzero because P has ﬁnite meets. Thus C is a
sheaf. A diagram chase shows that if C is a sheaf and E a subpresheaf, then
E is a sheaf if and only if for each x =

(cid:87)

E(x)

(cid:45)

xi, the diagram
(cid:81)

E(xi)

(cid:63)
C(x)

(cid:45)

(cid:81)

(cid:63)
C(xi)

is a pullback. The vertical arrows are just the inclusions. As we saw in 15.5.7,
the lower horizontal function is just the inclusion of C(x) into the set of
constant strings. It follows that this is essentially what the upper horizontal
arrow is. Now in order that a string of elements {si} ∈
E(xi) be constant,
it is necessary and suﬃcient that all the si be the same element s and that
s ∈ E(xi) for all i which means that σ(s) ≥ xi for all i. But this is just what
is required to have σ(s) ≥ x and s ∈ E(x).

(cid:81)

Continuing in this vein, it is possible to show the following.

15.6.9 Theorem For any Heyting algebra P , the category of fuzzy sets
based on P is equivalent to the full subcategory of the category of P + sheaves
consisting of the sheaves that are subsheaves of the near constant sheaves.

15.6.10 The introduction of P + instead of P is directly traceable to the
failure the two kinds of empty sets as mentioned in 15.6.5 to be the same.
The fact that the sheaves are subsheaves of the near constant sheaves is
really a reﬂection of the fact that in fuzzy set theory only one of the two
predicates of set theory is made to take values in P (or P +).

This shows up in the fact that in fuzzy set theory there is no fuzzy set of
fuzzy subsets of a fuzzy set. In other words, the P construction is missing.
Here’s why. Suppose S is a set, considered as a fuzzy set with σ(s) = 1 for
all s ∈ S. (Such a fuzzy set is called a crisp set.) Let x < y be two elements

15.7 External functors

403

of P and consider the subsets Sx = (S, σx) and Sy = (S, σy), with σx and
σy being the functions which are constant at x and y respectively. Then of
course, Sx (cid:54)= Sy (actually Sx is a proper subset of Sy), but it is clear that
when looking only at degrees of membership at level x or below, the two
subsets are equal. In fact, in the topos, the degree to which Sx equals Sy is
just x. But this predicate cannot be stated in the language of fuzzy sets and
the result is that there are not and cannot be power objects (unless P has
just one element).

The point is that there are two predicates in set theory, membership
and equality. In topos theory, both may be fuzzy, but in fuzzy set theory,
only membership is allowed to be. But P converts membership into equality
as explained in the preceding paragraph and so cannot be deﬁned in fuzzy
set theory. Thus fuzzy set theory, as currently implemented, lacks a certain
conceptual consistency.

One can try to reﬁne the deﬁnition of fuzzy set so as to allow fuzzy equality. The
obvious way to proceed is to deﬁne as objects triplets (S, σ, η), with (S, σ) as
above and η : S × S −→ P , interpreted as fuzzy equality. These must be subject
to the condition that the degree to which two elements are equal cannot exceed
the degree to which either one is deﬁned. The resultant category is equivalent
to the topos of sheaves on P +.

15.7 External functors

15.7.1 Category objects in a topos One of the tools proposed for pro-
gramming language semantics is the category of modest sets, which we will
describe in the next section. The category of modest sets is not a category in
the sense we have been using the word up until now: it is a category object
in another category, called the eﬀective topos.

Recall the sketch for categories that was described in detail in 10.1.5.
A model of this sketch in the category of sets is, of course, a category. A
model in a category C is called a category object in C . A homomorphism
between such category objects is called an internal functor between those
category objects.

Referring to the sketch, we see that a category object consists of four
∼= C1 ×C0
objects C0, C1, C2 and C3 such that C2
C1 ×C0 C1. There are arrows in C corresponding to unit, source, target and

∼= C1 ×C0 C1 and C3

404

Toposes

composition. The crucial commutative diagrams are:

(cid:104)id, u ◦ s(cid:105)

C2(cid:45)

C1

(cid:64)

(cid:64)
id

(cid:190)(cid:104)u ◦ t, id(cid:105)
(cid:161)

(cid:161)
id

(cid:161)

C1

C3

(cid:104)p1, c(cid:105)

C2(cid:45)

(cid:104)c, p3(cid:105)

c

(cid:63)
C2

(cid:63)
C1(cid:45)

c

(cid:64)

(cid:64)

(cid:64)(cid:82)

c

(cid:161)

(cid:161)(cid:170)

(cid:63)
C1

We may denote such a category object by C = (cid:104)C0, C1, uC, sC, tC, cC(cid:105)
since the remaining data are determined by these. As a matter of conve-
nience, we usually omit the indexes unless they are necessary for compre-
hension. If D = (cid:104)D0, D1, u, s, t, c(cid:105) is another category object, then an internal
functor f : D −→ C is given by homomorphisms f0 : D0 −→ C0 and f1 : D1
−→ C1 such that the following diagrams commute, where f2 : D2 −→ C2 is
the unique arrow for which pi ◦ f2 = f1 ◦ pi,

i = 1, 2.

D1

s

(cid:63)
D0

C1(cid:45)f1

s

(cid:63)
C0(cid:45)

f0

D2

c

(cid:63)
D1

C2(cid:45)f2

c

(cid:63)
C1(cid:45)

f1

D1

t

(cid:63)
D0

C1(cid:45)f1

t
(cid:63)
C0(cid:45)

f0

D0

C0(cid:45)f0

u

(cid:63)
D1

u

(cid:63)
C1(cid:45)

f1

(15.3)

15.7.2 External functors The notion of a functor from a category into
the category of sets can be extended to describe a functor from a category in
E to E itself. Such a functor is called an external functor. This construction
is based on the construction in Section 12.2 for Set. Theorem 12.3.7 gives an
equivalence of categories between external functors and the split opﬁbrations
which are produced by the Grothendieck construction, and so justiﬁes the
representation by split opﬁbrations of external functors deﬁned on a category
object.

Essentially, what we will do is use objects and arrows representing sets
and functions involved in the Grothendieck construction, ﬁnd enough cones

and commutative diagrams to characterize it, and take that as the deﬁnition
of external functor in an arbitrary category.

15.7 External functors

405

15.7.3 Let E be a category, and let

C = (C0, C1, source, target, unit, comp)

be a category object in E . An external functor C −→ E consists of data

(D0, D1, D2, d 0, d 1, u, π0, π1, p1, p2, c)

for which the Di are objects of E and the arrows have sources and targets
as indicated:

d i : D1 −→ D0,
u : D0 −→ D1
πi : Di −→ Ci,
pi : D2 −→ D1,
c : D2 −→ D1

i = 1, 2

i = 0, 1
i = 1, 2

D0 is the object corresponding to the disjoint union of the values of the
functor. Note that we are not given a functor F as we were in Section 12.2 –
we are being guided by Theorem 12.3.7 and the details of the Grothendieck
construction to deﬁne an external functor, and π0 represents the projection
(taking (x, C) to C in the case of the Grothendieck construction). D1 is the
object corresponding to the arrows of the category G(C, F ) as deﬁned in
Section 12.2, and π1 takes (x, f ) to f . Thus π0 and π1 together describe the
functor G(F ) in the case of the Grothendieck construction.

d 0 and d 1 are the source and target maps of that category, c is the

composition and u picks out the identities.

The data are subject to the requirements E–1 through E–4 below.
E–1 All three diagrams below must commute and (a) must be a pullback:
C1(cid:45)π1

C1(cid:45)π1

D1

D1

d 0

(cid:63)
D0

source

d 1

target

u

(cid:63)
C0(cid:45)
π0
(a)

(cid:63)
C0(cid:45)

(cid:63)
D0

π0
(b)

D0

C0(cid:45)
π1
(c)

(15.4)

That (a) is a pullback says in the case of the Grothendieck construction that,
up to unique isomorphism, D1 consists of elements of the form (x, f ) with
f an arrow of E and x ∈ F (C) where C is the source of f . This is part of

D1
(cid:54)

C1(cid:45)πo
(cid:54)
unit

406

Toposes

GS–2 (see Section 12.2). The commutation of (b) says that d1(x, f ) ∈ F (C(cid:48))
where C(cid:48) is the target of F ; that follows from GS–1 and GS–2 (there, x(cid:48)
must be in F (C(cid:48))). That of (c) says that u(x, C) must be (idC). In the case
of the Grothendieck construction that follows from the fact that F is given
as a functor.

E–2 The following diagram is a pullback:
D1(cid:45)p2

D2

p1

(cid:63)
D1

d 1
(cid:63)
D0(cid:45)

d 0
(d)

In the case of the Grothendieck construction this forces D2 to be the set of
composable pairs of arrows of G(C, F ).

E–3 The following diagram must commute:

D1
(cid:54)

p1

C1(cid:45)π1
(cid:54)
p1

D2

C2(cid:45)

π2

p2

(cid:63)
D1

p2

(cid:63)
C1(cid:45)

π1
(e)

π2 is deﬁned by Diagram (15.3) (called f2 there). In the case of the Grothen-
dieck construction this follows from GS–3: (x, g(cid:48)) composes with (x, f ) only
if g composes with f (but not conversely!).

E–4 The following diagrams must commute.

D2

C2(cid:45)π2

c

(cid:63)
D1

comp

(cid:63)
C1(cid:45)
π1
(f)

D2

c

(cid:63)
D1

D1(cid:45)p1

d 0
(cid:63)
D0(cid:45)

d 0
(g)

D2

c

(cid:63)
D1

D1(cid:45)p2

d 1
(cid:63)
D0(cid:45)

d 1
(h)

(15.5)

15.7 External functors

407

In the case of the Grothendieck construction, (f) says that π1 preserves
composition and (g) and (h) say that the composite has the correct source
and target.

As we have presented these diagrams, we have observed that they are all
true in the case of the Grothendieck construction in Set. In the case of the
Grothendieck construction,

(D0, D1, source, target, unit, comp)

is actually a category, hence a category object in Set. Moreover, π = (π0, π1)
is a functor, namely G(F ). That is actually true in any category, as seen in
the following.

15.7.4 Proposition Let

(D0, D1, D2, d 0, d 1, u, π0, π1, p1, p2, c)

be an external functor to a category object

C = (C0, C1, source, target, unit, comp)

in a category E . Then

(D0, D1, source, target, unit, comp)

is a category object in E and (π0, π1) is a functor in E .

The proof is a lengthy series of diagram chases.
The converse is true, too: up to some technicalities, an external functor
in Set arises from a functor to Set from a small category. That means we
said enough about it in E–1 through E–4 to characterize it.

15.7.5 Theorem Let

(D0, D1, D2, d 0, d 1, u, π0, π1, p1, p2, c)

be an external functor to a category

C = (C0, C1, source, target, unit, comp)

in Set. Deﬁne F : C −→ Set by
F–1 If C is an object of C , then F (C) = π−1

1 (C).

408

Toposes

F–2 If f : C −→ C(cid:48) is an arrow of C and x ∈ F (C), then F (f )(x) is the
target of the unique arrow α of D for which π1(α) = f and d 0(α) = x.

Then F : C −→ Set is a functor, and there is a unique isomorphism β : D
−→ G(C , F ) for which G(F ) ◦ β = π.

This theorem is essentially the discrete case of Theorem 12.3.7.
F–2 makes use of the fact that Diagram (15.4)(a) is a pullback. A sea-
soned categorist will simply name α ∈ F 2 as (x, f ), since he knows that
between any two pullbacks deﬁned by (15.4)(a) there is a unique isomorph-
ism respecting the projections π1 and d 0.

15.8 The realizability topos

The category of modest sets has been proposed as a suitable model for the
polymorphic λ-calculus. It is a subcategory of a speciﬁc topos, the realiz-
ability topos. Space limitations prevent us from giving a full exposition of
this topic, Here we describe how the realizability topos and the subcategory
of modest sets are constructed. Further references are [Carboni, Freyd and
Scedrov, 1988], [Rosolini, 1990], [Gray, 1991].

15.8.1 Realizability sets In the discussion below, we will be writing
f (x) where f is a partial function. It will be understood that f (x) is de-
ﬁned when we write this.

A realizability set is a pair A = (A, =A) where A is a set called the
carrier of A and =A: A × A −→ P(N ) is a function to sets of natural num-
bers (thought of as reasons that two elements are equal; in fact, they can
be thought of as the set of G¨odel numbers of proofs that they are). We
denote the value of this function at (a1, a2) ∈ A × A by [[a1 =A a2]], often
abbreviated to [[a1 = a2]]. This is subject to the following conditions:

REAL–1 There is a partial recursive function f such that for any a1, a2 ∈ A

and n ∈ [[a1 = a2]], f (n) ∈ [[a2 = a1]].

REAL–2 There is a partial recursive function of two variables g with the
property that if n ∈ [[a1 = a2]] and m ∈ [[a2 = a3]], then g(n, m) ∈
[[a1 = a3]].

This is made into a category by deﬁning an arrow from A = (A, =A) to
B = (B, =B) to be an equivalence class of partial functions φ : A −→ B such
that there is a partial recursive function f such that n ∈ [[a1 = a2]] implies
that f (n) ∈ [[φa1 = φa2]]. Two such arrows φ and ψ are equal if there is a
partial recursive f such that n ∈ [[a = a]] implies that f (n) ∈ [[φa = ψa]].

Note that the last deﬁnition implies that f is deﬁned on all elements

a ∈ A for which [[a = a]] (cid:54)= ∅. The other elements of A are irrelevant.

15.8 The realizability topos

409

15.8.2 This category is a topos. We will not prove this, but simply describe
some of the constructions required. To ﬁnd products, for example, ﬁrst choose
a recursive bijection f : N × N −→ N. If A = (A, =A) and B = (B, =B)
are realizability sets, the product is (A × B, =A × =B), where the latter is
deﬁned by

[[(a1, b1) = (a2, b2)]] = {f (n, m) | n ∈ [[a1 = a2]], m ∈ [[b1 = b2]]}

Notice that a choice of f is required to show that products exist. The
products thereby exist, but, owing to the uniqueness of categorical products,
do not depend in any way on the choice of the function.

Equalizers can be deﬁned as follows. If φ, ψ : A −→ B are two arrows their

equalizer is given by (A, =φ,ψ) where [[a1 =φ,ψ a2]] = [[φa1 = ψa2]].

Finally power objects can be constructed as follows. Let f denote a
pairing as above and also choose an enumeration ge of all the partial re-
cursive functions. The carrier of PA is [A −→ PN], all functions from A
to sets of natural numbers. If P and Q are two such functions, then we
will say that f (d, e) ∈ [[P = Q]] if for all n ∈ P (a) and m ∈ [[a = b]], we
have gd(f (n, m)) ∈ Q(b) and for all n ∈ Q(a) and m ∈ [[a = b]], we have
ge(f (n, m)) ∈ P (b).

This topos is called the realizability or eﬀective topos. It is due to
Martin Hyland [1982], although the basic idea goes back to S. Kleene. See
also [Rosolini, 1987].

15.8.3 Modest sets ‘Modest sets’ is used more-or-less interchangeably
to denote either a certain full subcategory of the category of realizability
sets or an internal category object of that topos. A great deal of eﬀort has
been put into describing the connection between the two. We will begin with
the former. The category of modest sets can be described directly and then
embedded into the realizability topos.

A modest set consists of A = (N, =A) where as usual N denotes the
natural numbers and =A is a partial equivalence relation or PER on
N, which means it is symmetric and transitive, but not necessarily reﬂexive.
We think of A as a quotient of a subobject of N; the subobject is the set of
n for which n =A n modulo the relation =A.

The category of modest sets has arrows from A to B deﬁned as partial
recursive functions f deﬁned on all n such that n =A n and such that n =A
m implies that f (n) =A f (m). Note that since the relation is symmetric and
transitive, as soon as there is some m with n =A m, it is also the case that
n =A n and so f (n) and f (m) are deﬁned.

The modest sets form a cartesian closed category. Choose, as above, an
enumeration ge of the partial recursive functions. Then [A −→ B] is the PER

410

Toposes

with relation given by d =[A−→B] e if and only if whenever n =A m then
gd(n) =B ge(m). The modest sets do not form a topos.

We embed the modest sets into the realizability sets by choosing a pairing
f and associating to the modest set A = (N, =A) the realizability set with
carrier N and e ∈ [[n = m]] if and only if n =A m and e = f (n, m). Although
this appears to depend on the choice of a pairing, it is easy to see that up
to isomorphism it does not.

In fact it cannot. The pairing is used only to show that products exist.
But their properties – in particular their isomorphism class – are independent
of the particular construction used to prove their existence. Similar remarks
apply to the cartesian closed structure, which does not depend on a particular
enumeration of the partial recursive functions.

15.8.4 The internal category of modest sets This is a very brief
glance at how one might internalize the description of modest sets to produce
a category object inside the category of realizability sets. Except by way of
motivation, this category object has no real connection with the category of
modest sets. Nevertheless, we will call it the internal category of modest
sets.

This internal category has the remarkable property that every internal
diagram in it has a limit. This is not possible for ordinary categories (unless
they are just posets), but the proof that it is not possible requires a property
of set theory which is not valid for the realizability sets (namely the axiom
of choice).

The construction is an exercise in internal expression. A modest set is
a relation on N with certain properties. The natural numbers object in the
category of realizability sets is the object (N, =N), where e ∈ [[n =N m]] if
and only if n = m = e. That is [[n =N m]] = {n} if n = m and is empty
otherwise. We will denote it by N. Then a modest set is a subset of N × N
with certain properties.

The set of objects of the internal category of modest sets is then a certain
set of subsets of N × N, which is the same as a subset of P(N × N). We want
to describe this subset as consisting of those relations that are symmetric
and transitive and double negation closed. The trick is to deﬁne endoarrows
s and t of P(N × N) that associate to a relation R the relations Rop and
R ◦ R, respectively. For s, this is easy. There is an arrow (cid:104)p2, p1(cid:105) : N × N
−→ N × N that switches the coordinates and we let s = P((cid:104)p2, p1(cid:105)).

For t, it is a little harder. By Yoneda, an arrow P(N × N) to itself can
be deﬁned by describing a natural transformation Hom(−, P(N × N)) to
itself. An element of Hom(A, P(N × N)) is, by the deﬁning property of P, a
subobject R ⊆ A × N × N. Given such an R, we deﬁne R(cid:48) to be the pullback

in the following diagram:

15.8 The realizability topos

411

R(cid:48)

R(cid:45)

(cid:63)
R

(cid:45)

(cid:63)
A × N

The two maps from R −→ A × N are the inclusion into A × N × N followed
by (cid:104)p1, p2(cid:105) and (cid:104)p1, p3(cid:105), respectively. You should think of R as being a set
of triples (a, n1, n2) and then R(cid:48) ⊆ A × N × N × N is the set of 4-tuples
(a, n1, n2, n3) such that (a, n1, n2) ∈ R and (a, n2, n3) ∈ R. Then the inclu-
sion of R(cid:48) into A × N × N × N followed by (cid:104)p1, p2, p4(cid:105) gives us an arrow
R(cid:48) −→ A × N × N whose image we denote by t(R). It is interpreted as the
set of (a, n1, n3) such that there is an n2 with both (a, n1, n2) ∈ R and
(a, n2, n3) ∈ R. We omit the proof that this construction from R to t(R) is
natural in A, but assuming that, it follows from the Yoneda Lemma that
this results from an endomorphism t of P(N × N).

Finally, the object M0 of objects is deﬁned as the limit of

P(N × N)

(cid:45)s
(cid:45)(cid:45)
t

P(N × N)

where the middle arrow is the identity. This is to be interpreted as the set
of relations that are ﬁxed under both s and t.

The object M0 is the object of objects of the internal category of modest
sets. The object of arrows is deﬁned as a subobject of the object [N −→ N](cid:101)
of partial arrows of N to N; namely those that satisfy the internal version
of the deﬁnition of the ordinary of modest sets. This construction is tedious,
but not diﬃcult, and we omit it.

16
Categories with
monoidal structure

Many of the categories that arise in computer science (and elsewhere) have
a binary operation on objects and arrows. This operation is rarely actually
associative, but is usually assumed associative up to natural isomorphism
and subject to certain coherence laws as we will explain. We also suppose
there is a unit object, which is not actually a unit, but is so up to a nat-
ural coherent isomorphism. Since the associativity and existence of a unit
characterize monoids, these categories are called monoidal.

This chapter may be read immediately after Chapter 13.

16.1 Closed monoidal categories

16.1.1 Deﬁnition A monoidal category is a category C equipped with
an object (cid:62) and a functor ⊗ : C × C −→ C . We use inﬁx notation so that
the value at (A, B) is written A ⊗ B. A monoidal category must have, in
addition, the natural isomorphisms a, r and l for all objects A, B and C
listed in MC–1 through MC–3 below, and these must make Diagrams MC–5
and MC–6 commute. The category is a symmetric monoidal category if
in addition it has the natural isomorphism SMC–4 and the diagrams SMC–7
through SMC–9 commute.

MC–1 a(A, B, C) : A ⊗ (B ⊗ C) −→ (A ⊗ B) ⊗ C;
MC–2 rA : A ⊗ (cid:62) −→ A;
MC–3 lA : (cid:62) ⊗ A −→ A.

SMC–4 s(A, B) : A ⊗ B −→ B ⊗ A.

MC–5

A ⊗ ((cid:62) ⊗ B)

a(A, (cid:62), B)

(cid:45)

(A ⊗ (cid:62)) ⊗ B

(cid:64)

(cid:64)
A ⊗ l(B)

(cid:64)

(cid:161)

(cid:161)
r(A) ⊗ B

(cid:161)

(cid:161)

(cid:64)

(cid:161)(cid:170)
(cid:64)(cid:82)
A ⊗ B

413

414

Categories with monoidal structure

MC–6

A ⊗ (B ⊗ (C ⊗ D))

(cid:161)

(cid:64)

(cid:161)

(cid:161)

(cid:161)

(cid:64)

(cid:64)

(cid:64)

A ⊗ a(B, C, D)
(cid:161)

(cid:161)

(cid:161)(cid:161)(cid:170)

a(A, B, C ⊗ D)
(cid:64)

(cid:64)

(cid:64)(cid:64)(cid:82)

A ⊗ ((B ⊗ C) ⊗ D)

(A ⊗ B) ⊗ (C ⊗ D)

a(A, B ⊗ C, D)

a(A ⊗ B, C, D)

(cid:63)

(A ⊗ (B ⊗ C)) ⊗ D

a(A, B, C) ⊗ D

(cid:45)

(cid:63)(cid:63)

((A ⊗ B) ⊗ C) ⊗ D

SMC–7

SMC–8

SMC–9

A ⊗ B
(cid:64)
id

(cid:64)

s(A, B)

(cid:45)

(cid:161)

B ⊗ A
(cid:161)
s(B, A)

(cid:64)

(cid:161)

(cid:161)(cid:170)
(cid:64)(cid:82)
A ⊗ B

s(A, (cid:62))

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

A

A ⊗ (cid:62)
(cid:64)
r(A)

(cid:64)

(cid:45)

(cid:161)

(cid:62) ⊗ A
(cid:161)
l(A)

A ⊗ (B ⊗ C)

a(A, B, C)

(cid:45)

(A ⊗ B) ⊗ C

A ⊗ s(B, C)

(cid:63)

A ⊗ (C ⊗ B)

s(A ⊗ B, C)

(cid:63)
C ⊗ (A ⊗ B)

a(A, C, B)

a(C, A, B)

(cid:63)

(A ⊗ C) ⊗ B

(cid:45)

s(A, C) ⊗ B

(cid:63)

(C ⊗ A) ⊗ B

16.1 Closed monoidal categories

415

Each of the diagrams listed above asserts the commutativity of a diagram
formed by composing isomorphisms built from instances of ⊗, a, r and l (and
s in the symmetric case). These diagrams are chosen to be the axioms because
assuming that they commute implies that any two parallel isomorphisms,
provided that they are constructed from ⊗, a, r and l and s using ⊗ and
composition, are the same. A precise statement of this fact is in Chapter
VII.2 of [Mac Lane, 1971].

In any monoidal category C , there is a functor A ⊗ − : C −→ C that takes

B to A ⊗ B and f : B −→ C to A ⊗ f : A ⊗ B −→ A ⊗ C.

16.1.2 Deﬁnition A monoidal category C is said to be closed if for each
object A of C , the functor A ⊗ − has a right adjoint.

If we denote the value at C of the right adjoint by A −◦ C (A appears
as a parameter since this is deﬁned for each object A), then the deﬁning
condition is an isomorphism, natural in B and C,

Hom(A ⊗ B, C)

∼=
−−→ Hom(B, A −◦ C)

(16.1)

In the symmetric case, it follows that

Hom(A ⊗ B, C) ∼= Hom(A, B −◦ C)

In general, the latter isomorphism fails in the non-symmetric case; there
we may want to suppose that there is, for each B a functor C (cid:55)→ C ◦− B
such that Hom(A ⊗ B, C) ∼= Hom(A, C ◦− B). We will not explore this point
further, but will suppose from now on that our monoidal structure is sym-
metric.

16.1.3 Example A category that has ﬁnite products is automatically a
symmetric monoidal category, using the categorical product for ⊗ and the
terminal object for (cid:62). The various isomorphisms can be constructed us-
ing the universal mapping property of products. For example, a(A, B, C) :
A × (B × C) −→ (A × B) × C is the map that is denoted (cid:104)(cid:104)proj1, proj1 ◦
proj2(cid:105), proj2 ◦ proj2(cid:105) (see 5.2.9 for an explanation of this notation). The
coherence is also automatic, essentially because of the uniqueness of the uni-
versal mappings. In Diagram MC–6, for example, both paths give the map

(cid:104)(cid:104)(cid:104)p1, p1 ◦ p2(cid:105), p1 ◦ p2 ◦ p2(cid:105), p2 ◦ p2 ◦ p2(cid:105) : A × (B × (C × D))

−→ ((A × B) × C) × D

where we have written p instead of proj.

416

Categories with monoidal structure

Cartesian closed categories are, of course, just monoidal closed categories
in which the product is the cartesian product. Thus any cartesian closed
category is monoidal closed, but there are many others.

A category with ﬁnite sums is also monoidal, using the sum for ⊗ and
the initial object for (cid:62). The veriﬁcation is essentially the same as for the
case of products. Set (and many other categories with both products and
sums) is therefore an example of a category with two inequivalent monoidal
structures on it.

16.1.4 Example In 2.1.14, we constructed the category Rel of relations,
whose objects are sets S, T , . . . , and in which an arrow S −→ T is a subset
α ⊆ S × T . The cartesian product of sets is not the product in this category
– the disjoint sum is both sum and product – but it is a functor of two
variables, that is a monoidal structure on Rel. We will denote it S ⊗ T to
avoid confusion with the categorical product. An arrow S ⊗ T −→ U in this
category is a subset of (S ⊗ T ) ⊗ U ∼= T ⊗ (S ⊗ U ). Thus Hom(S ⊗ T, U ) ∼=
Hom(T, S ⊗U ). Thus Rel is a closed monoidal category with S −◦ T = S ⊗T .
Observe that this is an example of a closed monoidal category in which
A −◦ B is not a structure built on Hom(A, B): A −◦ B = A⊗B is the cartesian
product (in Set, not Rel!) of A and B, whereas Hom(A, B) is the powerset
of that cartesian product.

We return to this example in Example 16.3.3.

16.1.5 Subsets of a monoid Here is an example that is a poset viewed
as a category. Let M be a monoid and C denote the category whose objects
are the subsets of M with inclusions as the only morphisms. If A and B are
subsets of M , let A ⊗ B = {ab | a ∈ A and b ∈ B}. Deﬁne A −◦ C = {b ∈
M | ab ∈ C for all a ∈ A}. Then it is easy to verify that A ⊗ B ⊆ C if and
only if B ⊆ A −◦ C. If we deﬁne C ◦− B = {a ∈ M | ab ∈ C for all b ∈ B}, it
is equally easy to see that A ⊗ B ⊆ C if and only if A ⊆ C ◦− B.

16.1.6 Sup semilattices Another example is the category of sup semi-
lattices, (see 5.4.6), which also illustrates another principle, that it is often
much easier to give an explicit description of the −◦ operation than of the
⊗. If K and L are sup semilattices, then K −◦ L is deﬁned to be the set of
all sup-semilattice homomorphisms from K to L. If f and g are such homo-
morphisms, then their sup is deﬁned by (f ∨ g)(x) = f (x) ∨ g(x). The bottom
element is the constant function at the bottom element of L. It is easily seen
that with these deﬁnitions K −◦ L is a sup semilattice.

To get the monoidal structure, we will construct the left adjoint to the
functor K −◦ −. The existence of the left adjoint also follows from the adjoint
functor theorem (references to this are given after Theorem 13.3.7).

16.2 Properties of A −◦ C

417

First, form the free sup semilattice generated by K × L. It has elements
of the form (x1, y1) ∨ (x2, y2) ∨ · · · ∨ (xn, yn) with x1, x2, . . . , xn ∈ K and y1,
y2, . . . , yn ∈ L. These speciﬁcally include the empty sup 0. We then form the
quotient semilattice gotten by all identiﬁcations of the form (x1, y)∨(x2, y) =
(x1 ∨ x2, y) and (x, y1) ∨ (x, y2) = (x, y1 ∨ y2). In addition, we must identify
the bottom element of the semilattice, which is the empty sup, with (x, 0)
for any x ∈ K and with (0, y) for any y ∈ L These identiﬁcations have to
be made compatible with the semilattice structure so that whenever two
elements are identiﬁed, their joins with any third element are also identiﬁed.
It is instructive to see why any (x, 0) has to be identiﬁed with 0. First, let
us denote the image of (x, y) in K ⊗ L by x ⊗ y. Not every element of K ⊗ L
has the form x ⊗ y, but it is generated by such elements. The isomorphism
Hom(K ⊗ L, M ) ∼= Hom(L, K −◦ M ) can be described as follows. If f : K ⊗ L
−→ M corresponds to (cid:101)f : L −→ K −◦ M , then for y ∈ L, (cid:101)f (y) : K −→ M is
deﬁned by (cid:101)f (y)(x) = f (x ⊗ y). In particular, (cid:101)f (0) is required to be the 0
homomorphism, in order to be a homomorphism of sup semilattices. Thus
f (x ⊗ 0) = (cid:101)f (0)(x) = 0. In particular, take M = K ⊗ L and choose f = id
to conclude that x ⊗ 0 = 0. A similar argument will show that 0 ⊗ y = 0 as
well, but in fact, it is not hard to show symmetry of ⊗ directly.

The crucial property of sup semilattices exploited here is that sup semilattices
are determined by operations, ∨ and 0 that are homomorphisms of the sup
semilattice structure. Thus when L is a sup semilattice, ∨ : L × L −→ L is not
just a function but a semilattice homomorphism. It is fairly uncommon for an
equational theory to have the property that its operations are homomorphisms
of the theory, but when it does, constructions analogous to the above will always
give a monoidal closed structure.

Many other examples of closed monoidal categories are given in [Mac
Lane, 1971]. Applications are discussed in [Asperti and Longo, 1991], [Cor-
radini and Asperti, 1993], [Marti Oliet and Meseguer, 1991] and [Bartha,
1992].

16.2 Properties of A −◦ C

Monoidal closed categories exemplify one of the earliest perceptions of cate-
gory theory, that a category is quite special if the set of arrows between any
two objects is, in some natural way, also an object of the category. Thus, al-
though it is much commoner to have some kind (or many kinds) of monoidal
structure on a category than to have a closed structure, it is usually easier
to deﬁne the closed structure, when it exists. This is well illustrated in the
example of semilattices given in 16.1.6.

418

Categories with monoidal structure

16.2.1 The internal hom Another aspect of this perception is that A −◦ C
is called the internal hom of A to C and indeed it has properties similar
to those of the ‘external’ (that is the set-valued) hom functor Hom(A, C).
For example, for each C, A (cid:55)→ A −◦ C is also functorial in A, albeit con-
travariantly. (For each A, C (cid:55)→ A −◦ C is a functor in C by deﬁnition.) This
means that there is a natural way of deﬁning, for each map f : A(cid:48) −→ A a
map f −◦ C : A −◦ C −→ A(cid:48) −◦ C in such a way that the isomorphism (16.1)
is natural in all three arguments. This generalizes Proposition 6.2.1.

Another aspect is illustrated by the following, which internalizes the ad-
junction. It is a generalization of isomorphism (6.1) and Proposition 6.2.2.

16.2.2 Proposition In any monoidal closed category, there is a natural
equivalence (of functors of three variables)

(A ⊗ B) −◦ C ∼= B −◦ (A −◦ C)

Proof. The proof uses the Yoneda Lemma (Theorem 4.5.3 of Chapter 4) and
the associativity isomorphism. The naturality will appear as Exercise 1. At
this point, we conﬁne ourselves to constructing the isomorphism. We have,
for any object D,

Hom(D, (A ⊗ B) −◦ C) ∼= Hom((A ⊗ B) ⊗ D, C)

∼= Hom(A ⊗ (B ⊗ D), C)

∼= Hom(B ⊗ D, A −◦ C)

∼= Hom(D, B −◦ (A −◦ C))

Each of these isomorphisms is easily seen to be natural in D and thus we
conclude from the Yoneda Lemma that (A ⊗ B) −◦ C ∼= A −◦ (B −◦ C).

16.2.3 Example Let M be a commutative monoid. Recall from 3.2.1 that
an M -action is a set S together with a function α : M × S −→ S subject to
certain conditions. We generally denote α(m, s) by ms and never mention α
explicitly. Suppose from now on that M is commutative. If S and T are M -
actions, then there are two functions M ×S ×T −→ S ×T , one taking (m, s, t)
to (ms, t) and the other taking that element to (s, mt). The coequalizer of
these two maps is denoted S ⊗M T or simply S ⊗ T if M is understood ﬁxed.
If we denote the class containing (s, t) by s ⊗ t, then S ⊗ T can be thought of
as consisting of elements s ⊗ t, s ∈ S and t ∈ T , subject to the relation that
ms ⊗ t = s ⊗ mt for m ∈ M . It is left as an exercise to show that this gives
a monoidal structure on M -act with unit action the multiplication of M on
itself. It is also a closed structure, given by deﬁning S −◦ T to be the set of
equivariant maps S to T with mf deﬁned by (mf )(s) = m(f (s)) = f (ms),
the latter equality from the fact that f is equivariant.

16.2 Properties of A −◦ C

419

16.2.4 Evaluation and composition There are certain derived morphisms
in a monoidal closed category, using the adjunction. For any objects A
and B, the identity A −◦ B −→ A −◦ B corresponds to an arrow e(A, B) :
A ⊗ (A −◦ B) −→ A called evaluation since it internalizes the evaluation
map. This is natural in A and B. We can then derive an arrow c(A, B, C)
deﬁned as the map (A −◦ B) ⊗ (B −◦ C) −→ A −◦ C that corresponds under
the adjointness to the map

A ⊗ (A −◦ B) ⊗ (B −◦ C)

e(A, B) ⊗ id

−−−−−−−−−−→ B ⊗ (B −◦ C)

e(B, C)
−−−−−−−→ C

The arrow c(A, B, C), which is also natural in all three variables, internalizes
the composition arrow.

16.2.5 Cotriples in closed monoidal categories Let G = (G, (cid:178), δ) be
a cotriple on C . The Kleisli category (often called the co-Kleisli category)
K = K (G) has the same objects as C and the hom sets are deﬁned by
K (A, B) = C (GA, B). The composite of f : GA −→ B and g : GB −→ C is
g ◦ Gf ◦ δA. This is the dual construction to the Kleisli category of a triple
and the veriﬁcations are the same.

Note that we are using the name of the category to denote the hom sets. This
notation is especially useful when we are dealing with two categories that have
the same objects.

One of the most important properties of the Kleisli category of a cotriple
is the following. It is used to construct models of classical logic inside linear
logic.

16.2.6 Theorem Suppose G = (G, (cid:178), δ) is a cotriple on a symmetric monoidal
closed category C with the property that for all objects A and B of C , there
are natural isomorphisms between the two variable functors G(− × −) ∼=
G− ⊗ G−. Then the Kleisli category for the cotriple is cartesian closed.

Proof. Let K denote the Kleisli category. Then we have, for any objects A,
B and C of C (and therefore of K ),

K (A, B × C) ∼= C (GA, B × C) ∼= C (GA, B) × C (GA, C)

∼= K (A, B) × K (A, C)

This isomorphism is clearly natural in A, which shows that, in K , B × C
is a product of B and C. (The same argument would work for any limit.)
Then we have, again for any objects A, B and C of C ,

K (A × B, C) ∼= C (G(A × B), C) ∼= C (GA ⊗ GB, C)

∼= C (GB, GA −◦ C) ∼= K (B, GA −◦ C)

420

Categories with monoidal structure

so that the functor GA −◦ − is right adjoint to A × − in K .

16.2 Properties of A −◦ C

421

16.2.7 Exercises

1. Show that the isomorphism of Proposition 16.2.2 is natural.

2. Show that when M is a commutative monoid, the category M -act as
described in 16.2.3 is a monoidal closed category.

Note: The following exercise is more of a project than an exercise. Anyone
who completes it should understand functors and natural transformations
quite thoroughly, when ﬁnished.

3. a. Suppose F : Ob(A ) × Ob(B) −→ Ob(C ) is an object function that we
want to complete to a functor. Show that what has to be done is to ﬁnd,

1. for each object A of A , a functor F (A, −) : B −→ C ;
2. for each object B of B, a functor F (−, B) : A −→ C ; such that
3. for each f : A −→ A(cid:48) of A and g : B −→ B(cid:48) of B the square

F (A, B)

F (A, g)

(cid:45)

F (A, B(cid:48))

F (f, B)

(cid:63)
F (A(cid:48), B)

(cid:45)

F (A(cid:48), g)

F (f, B(cid:48))
(cid:63)
F (A(cid:48), B(cid:48))

commutes.

b. Show that the third condition above is equivalent to each of the two

statements

1. for each map f : A −→ A(cid:48), F (f, −) : F (A, −) −→ F (A(cid:48), −) is a natural

transformation;

2. for each map g : B −→ B(cid:48), F (−, g) : F (−, B) −→ F (−, B(cid:48)) is a natural

transformation.

c. Show that a transformation α between functors F, G : A × B −→ C is
natural if and only if for each object A of A , the transformation α(A, −) :
F (A, −) −→ G(A, −) is natural between functors B −→ C and similarly for
each object B of B, the transformation α(−, B) is natural.

d. Show that in a monoidal closed category there is a natural way of
deﬁning, for each map f : A(cid:48) −→ A, a map f −◦ C : A −◦ C −→ A(cid:48) −◦ C and
for each map h : C −→ C(cid:48) a map A −◦ h : A −◦ C −→ A −◦ C(cid:48) in such a way
that the isomorphism Hom(A ⊗ B, C) ∼= Hom(B, A −◦ C) is natural in all
three arguments. (Hint: Use the Yoneda lemma.)

422

Categories with monoidal structure

16.3 ∗-autonomous categories

16.3.1 Deﬁnition Let C be a symmetric monoidal closed category. A
functor (−)∗ : C op −→ C is a duality functor if there is an isomorphism
∼=
−−→ B∗ −◦ A∗, natural in A and B, such that for all objects

d(A, B) : A −◦ B
A, B and C,

(A −◦ B) ⊗ (B −◦ C)

c(A, B, C)

(cid:45)

A −◦ C

d(A, B) ⊗ d(B, C)

d(A, C)

(cid:63)
(B∗ −◦ A∗) ⊗ (C∗ −◦ B∗)

(cid:45)
c(C∗, B∗, A∗) ◦ s

(cid:63)
C∗ −◦ A∗

commutes. In the bottom arrow, s = s(B∗ −◦ A∗, C∗ −◦ B∗). Then we deﬁne
a ∗-autonomous category to be a symmetric monoidal closed category with
a given duality functor.

The discussion of ∗-autonomous categories in this section omits many
details. The basic theory is in [Barr, 1979]. More recent developments are
given in [Barr, 1996a] and [Barr, 1995]. ∗-autonomous categories form a
model of linear logic [Barr, 1991], which has become important in modeling of
parallel processes and is closely related to Petri nets and event structures. A
good introduction, with references, to linear logic, is Yves Lafont’s Appendix
B of [Girard, Taylor and Lafont, 1989]. The connection between ∗-autono-
mous categories and linear logic is described in [Asperti and Longo, 1991],
sections 4.4 and 5.5, and ∗-autonomous categories are used in modelling
processes in [Pavlovi´c and Abramsky, 1997].

16.3.2 Properties of ∗-autonomous categories There is much redun-
dancy in the data specifying a ∗-autonomous category. Given the duality, it
is not hard to show that the ⊗ and −◦ are related by the equations:

A ⊗ B ∼= (A −◦ B∗)∗

A −◦ B ∼= (A ⊗ B∗)∗

so that only the (−)∗ and either −◦ or ⊗ need be given explicitly. Of course,
various isomorphisms, maps and coherences must still be given. The details
can be found (for the not necessarily symmetric case) in [Barr, 1995]. It
turns out that it is usually most convenient to describe the −◦, since when
the objects are structured sets, A −◦ B usually turns out to be the set of
structure preserving functions of A −→ B, equipped with a certain structure
itself.

There is a second monoidal structure in a ∗-autonomous category, which
we will denote by ⊕, deﬁned by A ⊕ B = (A∗ ⊗ B∗)∗. The unit for this

16.3 ∗-autonomous categories

423

monoidal structure is (cid:62)∗, which we will denote ⊥, since A ⊕ ⊥ = (A∗ ⊗
⊥∗)∗ ∼= (A∗ ⊗ (cid:62))∗ ∼= A∗∗ ∼= A. Since A∗ ⊕ C ∼= A −◦ C, there is a one-one
correspondence between arrows A ⊗ B −→ C and arrows B −→ A∗ ⊕ C. This
should be thought of as being analogous to the equivalence between the
logical statements a ∧ b ⇒ c and b ⇒ ¬a ∨ c.

It is also possible to describe a ∗-autonomous category in terms of a sym-
metric closed monoidal category with an object ⊥ subject to the condition
that for every A, the map A −→ ((A −◦ ⊥) −◦ ⊥) that corresponds under the
adjunction to

(A −◦ ⊥) ⊗ A

s(A −◦ ⊥, A)

−−−−−−−−−−→ A ⊗ (A −◦ ⊥)

e(A, ⊥)

−−−−−−→ ⊥

is an isomorphism. The reason is that we have

A∗ ∼= (cid:62) −◦ A∗ ∼= A −◦ (cid:62)∗ ∼= A −◦ ⊥

which shows that the duality is determined by −◦ and ⊥. We say that ⊥ is the
dualizing object for the duality. It is clearly determined up to isomorphism
as the dual of (cid:62).

However, one of the most important ways (for computing science) of
constructing ∗-autonomous categories does not work this way in that the
−◦ and ⊗ are constructed together. That is the so-called Chu construction,
described in 16.4 below. We ﬁrst present a familiar example.

16.3.3 Example The category Rel of sets and relations is a ∗-autono-
mous category. We saw that it was closed monoidal in Example 16.1.4. Since
Hom(S, T ) ∼= Hom(T, S) (both being the powerset of the cartesian product
of S and T ), it follows that we have a duality by letting S∗ = S. This gives a
∗-autonomous category. In fact, it is an example of what is called a compact
∗-autonomous category, that is one in which A −◦ B ∼= A∗ ⊗ B.

16.3.4 Exercise

1. a. Show that a ﬁnite sup semilattice is actually a lattice; that is, there is
a greatest element and every pair of elements has an inf.

and if g : M −→ L is deﬁned by g(y) =

b. Show that if f : L −→ M is a sup preserving map of ﬁnite semilattices,
(cid:87)
{x | f (x) ≤ y}, then g preserves inf.
c. For a semilattice L, let Lop denote the same set of elements with the
directions of ≤ reversed. The preceding implies that if L is a ﬁnite semilattice,
so is Lop. Show that with L∗ = Lop, the category of ﬁnite semilattices is a
∗-autonomous category.

424

Categories with monoidal structure

16.4 The Chu construction

Chu [1978, 1979] describes a construction that begins with a symmetric
monoidal closed category and an object in it to use as dualizing object. He
constructs from this a ∗-autonomous category that is closely related to the
original category and has the chosen object as dualizing object. There is
a non-symmetric version of this construction, but it is much more compli-
cated [Barr, 1995], see also [Barr, 1996b].

Suppose that V is a symmetric monoidal closed category and let D denote
a ﬁxed object of V . We deﬁne a category A that has as objects triples
(V, V (cid:48), (cid:104)−, −(cid:105)) where V and V (cid:48) are objects of V and (cid:104)−, −(cid:105) : V ⊗ V (cid:48) −→ D
is an arrow of V . We call (cid:104)−, −(cid:105) a pairing and we usually omit it in the
notation, writing (V, V (cid:48)) for an object of A . This notation means we have in
mind a pairing from V ⊗ V (cid:48) to D, and moreover this pairing will always be
denoted (cid:104)−, −(cid:105). An arrow (f, f (cid:48)) : (V, V (cid:48)) −→ (W, W (cid:48)) of A consists of a pair
of arrows f : V −→ W and f (cid:48) : W (cid:48) −→ V (cid:48) (note the direction of the second
arrow) such that

V ⊗ W (cid:48)

f ⊗ W (cid:48)

(cid:45)

W ⊗ W (cid:48)

V ⊗ f (cid:48)

(cid:63)
V ⊗ V (cid:48)

(cid:104)−, −(cid:105)

(cid:63)
D(cid:45)

(cid:104)−, −(cid:105)

commutes. This says that the arrows (V, V (cid:48)) −→ (W, W (cid:48)) consist of all pairs

(f, f (cid:48)) ∈ Hom(V, V (cid:48)) × Hom(W (cid:48), W )

that give the same element of Hom(V ⊗ W (cid:48), D) or that

Hom((V, V (cid:48)), (W, W (cid:48)))

(cid:45)

Hom(V, W )

(cid:63)
Hom(W (cid:48), V (cid:48))

(cid:45)

(cid:63)
Hom(V ⊗ W (cid:48), D)

is a pullback. This observation is the key to the construction of the monoidal
closed structure in A .

The next step in the construction is to make the set of arrows into an

16.4 The Chu construction

425

object of V . We deﬁne V ((V, V (cid:48)), (W, W (cid:48))) so that

V ((V, V (cid:48)), (W, W (cid:48)))

(cid:45)

V −◦ W

(cid:63)
W (cid:48) −◦ V (cid:48)

(cid:63)
(V ⊗ W (cid:48)) −◦ D

(cid:45)

is a pullback. Here the arrow on the right side is described as follows. The
arrow (cid:104)−, −(cid:105) : W ⊗ W (cid:48) −→ D corresponds to an arrow W −→ W (cid:48) −◦ D (the
symmetry is involved here too) and then we have a composite arrow

V −◦ W −→ V −◦ (W (cid:48) −◦ D)

∼=
−−→ (V ⊗ W (cid:48)) −◦ D

The lower arrow in the diagram is similar.

If (V, V (cid:48)) is an object of A , then so is (V (cid:48), V ) using V (cid:48) ⊗ V

V ⊗ V (cid:48)

(cid:104)−, −(cid:105)

−−−−−−→ D. We denote it by (V, V (cid:48))∗. It is clear that

s(V (cid:48), V )
−−−−−−−→

Hom((V, V (cid:48)), (W, W (cid:48))) ∼= Hom((W, W (cid:48))∗, (V, V (cid:48))∗)

so that (−)∗ is a duality on A . Now we can give the main deﬁnitions. We
let

(V, V (cid:48)) −◦ (W, W (cid:48)) = (V ((V, V (cid:48)), (W, W (cid:48))), V ⊗ W (cid:48))

(V, V (cid:48)) ⊗ (W, W (cid:48)) = (V ⊗ W, V ((V, V (cid:48)), (W, W (cid:48))∗))

16.4.1 Separated and extensional Chu objects Suppose that E /M
is a factorization system (see 2.10 in Chapter 2) on V . Then we say that the
Chu object (V, V (cid:48)) is M -separated if the arrow V −→ V (cid:48) −◦ D belongs to M
and is M -extensional if the arrow V (cid:48) −→ V −◦ D belongs to M . When the
M remains ﬁxed, we often omit it and speak of separated and extensional
objects.

The reason for these names is this. We often think of a pair (V, V (cid:48)) as consisting
of an object and a set of descriptions of scalar-valued functions on it. Separability
is the existence of enough such descriptions in V (cid:48) to distinguish (or separate) the
elements of V , while extensionality is the word used to name the property of func-
tions that two are equal if their values on all elements of their domain are equal.
Functions have this property, but programs for computing them do not necessarily.

We denote the full subcategories of separated objects by

Chus = Chus(V , D)

426

Categories with monoidal structure

and of extensional objects by

Chue = Chue(V , D)

We follow Vaughan Pratt in denoting the full subcategory of objects that are
both separated and extensional by chu = chu(V , D). Since Chus is evidently
the dual of Chue, it is immediate that chu is self-dual. It is useful to ask if
chu is also ∗-autonomous.

We also suppose that the factorization satisﬁes the following two condi-

tions

FC–1 Every arrow in E is an epimorphism;
FC–2 if m ∈ M , then for any object A of V , the induced A −◦ m is in M .

We will show that under these conditions, the category chu(V , D) of
separated, extensional objects (with respect to M ) in Chu(V , D) is a ∗-
autonomous category.

16.4.2 We begin by treating a somewhat common situation in a ∗-auton-
omous category. Suppose A is a such a category and Al is a reﬂective full sub-
⊥ is quite evidently a
category with reﬂector l. The full subcategory Ar = Al
coreﬂective subcategory with rA = (lA⊥)⊥ as coreﬂector. Let Arl = Vr ∩ Al.
Assume that when A is an object of Ar, then so lA, which is then an object
of Arl. This is readily seen to imply that when A is an object of Al, so is
rA. It is also immediate that under these conditions, l and r induce left and
right adjoints, resp., to the inclusions of Arl −→ Ar and Arl −→ Al.

16.4.3 Proposition Under the above assumptions Ar ⊗ Ar ⊆ Ar if and
only if Ar −◦ Al ⊆ Al.

Proof. These follow immediately from the identities, valid in any ∗-autono-
mous category

A −◦ B ∼= (A ⊗ B⊥)⊥

A ⊗ B = (A −◦ B⊥)⊥

16.4.4 Theorem Suppose A is a ∗-autonomous category and Al is a re-
⊥ invariant as in 16.4.2. Sup-
ﬂective subcategory whose reﬂector l leaves Al
pose that the unit object belongs to Ar and that the equivalent conditions of
16.4.3 are satisﬁed. Then Arl is a ∗-autonomous category with unit object
l(cid:62), dualizing object rD, tensor A × B = l(A ⊗ B) and A − B = r(A −◦ B).

16.4 The Chu construction

427

Proof. We have, for any objects A and B of Arl, using the facts that B and
A −◦ B belong to Al,

Hom(l(cid:62) × A, B) ∼= Hom(l(l(cid:62) ⊗ A), B) ∼= Hom(l(cid:62) ⊗ A, B)

∼= Hom(l(cid:62), A −◦ B) ∼= Hom((cid:62), A −◦ B) ∼= Hom(A, B)

and so, by the Yoneda lemma, we conclude that l(cid:62) × A ∼= A.

We have, for any objects A, B, C, and D of Arl,

Hom(A, (B × C) − D) ∼= Hom(A, r((B × C) −◦ D))

∼= Hom(A, (B × C) −◦ D)

∼= Hom(A ⊗ (B × C), D) ∼= Hom((B × C), A −◦ D)

∼= Hom(l(B ⊗ C), A −◦ D) ∼= Hom(B ⊗ C, A −◦ D)

∼= Hom(A ⊗ B ⊗ C, D)

and

Hom(A, B − (C − D)) ∼= Hom(A, r(B −◦ (C − D)))

∼= Hom(A, B −◦ (C − D))

∼= Hom(A ⊗ B, C − D)

∼= Hom(A ⊗ B, r(C −◦ D))

∼= Hom(A ⊗ B, C −◦ D) ∼= Hom(A ⊗ B ⊗ C, D)

By letting A = l(cid:62), we see that Hom(B × C, D) ∼= Hom(B, C − D) and by
Yoneda we get (B × C) − D ∼= B − (C − D), which is the internal version
and implies the associativity of the tensor. Thus we have a ∗-autonomous
category.

16.4.5 The separated extensional subcategory We apply the above
construction to show that under the conditions FC–1 and FC–2 on a fac-
torization system E /M , the full subcategory of M -separated and M -exten-
sional objects forms a ∗-autonomous category.

16.4.6 Theorem Suppose the category V has pullbacks and E /M is a
factorization system that satisﬁes FC–1 and FC–2. Then for any object D,
the category chu(V , D) of M -separated, and M -extensional objects of Chu
is ∗-autonomous.

We give the proof as a series of propositions.

428

Categories with monoidal structure

16.4.7 Proposition The inclusion of Chus −→ Chu has a left adjoint.
Proof. Let A = (V, V (cid:48)) be an object of Chu. Factor V −→ V (cid:48)⊥ as V −→→ (cid:101)V
(cid:41)−→ V (cid:48)⊥, where we adopt the usual notation of writing −→→ for an arrow of
E and (cid:41)−→ for an arrow of M . Then sA = ( (cid:101)V , V (cid:48)) is a separated object and
we have an obvious map A −→ sA. If (f1, f2) : (V, V (cid:48)) −→ (W, W (cid:48)) is a map
in Chu(V , K) and (W, W (cid:48)) is separated, the unique diagonal ﬁll-in in the
square

V

(cid:101)V(cid:45)(cid:45)

(cid:63)
V (cid:48)⊥

(cid:63)
(cid:63)
W (cid:48)⊥(cid:45)(cid:45)
W
gives the required map sA −→ B.

It follows that the inclusion Chue −→ Chu has a right adjoint, which we

denote e.

16.4.8 Proposition FC–1 implies that when the object (V, V (cid:48)) of the cat-
egory Chu(V , D) is separated, so is e(V, V (cid:48)) and similarly if (V, V (cid:48)) is ex-
tensional, so is s(V, V (cid:48)).
Proof. Suppose that A = (V, V (cid:48)) is a separated object. Then eA = (V, (cid:101)V (cid:48))
where V (cid:48) −→→ (cid:101)V (cid:48) (cid:41)−→ V ⊥. By transposing, this gives V −→ ( (cid:101)V (cid:48))⊥ −→ V (cid:48)⊥
whose composite belongs to M and so, by Proposition 2.10.7, does the ﬁrst
factor V −→ ( (cid:101)V (cid:48))⊥ which means that eA is still separated. The proof that
sA is extensional when A is is similar (also dual).

16.4.9 Proposition FC–2 implies that when A and B are extensional, so
is A ⊗ B.
Proof. Let A = (V, V (cid:48)) and B = (W, W (cid:48)) be extensional. The second com-
ponent of A ⊗ B is the pullback

P

(cid:45)

V −◦ W (cid:48)

(cid:63)
W −◦ V (cid:48)

(cid:45)

(cid:63)
W −◦ V ⊥ ∼= V −◦ W ⊥ ∼= (V ⊗ W )⊥

It follows from FC–2 that both arrows W −◦ V (cid:48) −→ W −◦ V ⊥ and V −◦ W (cid:48)
−→ V −◦ W ⊥ lie in M . But it is a general property of factorization systems
that M is closed under pullback and composition, whence the arrow P −→
(V ⊗ W )⊥ also lies in M .

The results of Section 16.4.4 now prove the theorem.

16.4 The Chu construction

429

16.4.10 Examples The ﬁrst example is Chu(Set, 2). An object is simply
a pair (S, S(cid:48)) of sets, together with a function S × S(cid:48) −→ 2. Equivalently, it
is a subset of S × S(cid:48), otherwise known as a relation between S and S(cid:48). The
extensional objects are those for which S(cid:48) is, up to isomorphism, a set of
subsets of S and then (cid:104)s, s(cid:48)(cid:105) = 1 if s ∈ s(cid:48) and 0 otherwise. The separated
ones are those for which, given s1, s2 ∈ S, there is at least one s(cid:48) ∈ S(cid:48) with
either s1 ∈ s(cid:48) and s2 /∈ s(cid:48) or vice versa. A set together with a set of subsets
is the beginnings of a topological space and the separation condition is the
same as that of a T1 topological space. This example has been intensively
studied by Vaughan Pratt and his students.

A second example is given by taking V to be the category of vector spaces
over a ﬁeld F . The category of ﬁnite dimensional vector spaces is already a
∗-autonomous category with the set of linear transformations between two
spaces as internal hom and the usual vector space dual as the duality op-
erator. It is easily seen to be a ∗-autonomous subcategory of Chu(V , F ). It
is also a ∗-autonomous subcategory of the separated extensional subcate-
gory chu(V , F ). There is one distinctive feature of the separated extensional
subcategory worth noting. In that case (and so far as is known only in that
case), the tensor product and internal hom of separated extensional objects
is already separated and extensional and there is no reason to apply the
reﬂector and coreﬂector, respectively (see [Barr, 1996c]).

Solutions to the exercises

Solutions for Chapter 1

Section 1.2

1. Suppose h is surjective, and suppose Hom(h, T )(f ) = Hom(h, T )(g). Then f ◦
h = g ◦ h. Let x ∈ S, and let w ∈ W satisfy h(w) = x (using surjectivity of h). Then
f (x) = f (h(w)) = g(h(w)) = g(x). Since x was arbitrary, this shows that f = g, so
that Hom(h, T ) is injective. Conversely, suppose that h is not surjective. This means
there is a particular x ∈ S which is not h(w) for any w ∈ W . Let t, u ∈ T be two
distinct elements of T . Let f : S −→ T be the constant function with value t. Let g : S
−→ T take x to u and all other elements to t. Then Hom(h, T )(f ) = Hom(h, T )(g),
so Hom(h, T ) is not injective.

2. a. To show that the mapping is injective, suppose (cid:104)f, g(cid:105) = (cid:104)f (cid:48), g(cid:48)(cid:105). Then for any
x ∈ X,

(f (x), g(x)) = (cid:104)f, g(cid:105)(x) = (cid:104)f (cid:48), g(cid:48)(cid:105)(x) = (f (cid:48)(x), g(cid:48)(x))

The coordinates of these pairs must be the same, so f (x) = f (cid:48)(x) and g(x) = g(cid:48)(x)
for all x ∈ X. Hence f = f (cid:48) and g = g(cid:48), so (f, g) = (f (cid:48), g(cid:48)). To get surjectivity,
suppose that q : X −→ S × T is any function. Deﬁne f : X −→ S by requiring that
f (x) be the ﬁrst coordinate of the pair q(x) for all x ∈ X; in other words, f (x) =
proj1(q(x)). Similarly set g(x) = proj2(q(x)). Then the mapping of the problem
takes (f, g) to q, so it is surjective.
b. The pair (proj1, proj2).

3. a. Deﬁne ψ : Hom(S ∪ T, V ) −→ Hom(S, V ) × Hom(T, V ) by ψ(h : S ∪ T −→ V ) =
(h|S, h|T ), where h|S denotes the restriction of h to the subset S of S ∪ T . It is easy
to see that ψ is the inverse function of φ.

b. It is (i, j), where i is the inclusion of S in S ∪ T and j is the inclusion of T

in S ∪ T .

4. a. Deﬁne ψ : Hom(A, PB) −→ Rel(A, B) by

ψ(f : A −→ PB) = {(a, b) | b ∈ f (a)}

Then ψ is inverse to φ.

b. The map a (cid:55)→ {a}.
c. The opposite of the ‘element of’ relation: If Y is a subset of B and b ∈ B then

Y is related to b if and only if b ∈ Y .

431

432

Solutions for section 1.3

Section 1.3

1. The graph

a

s
−→−→
t

label
−−−−→ l

n

expresses the concept. Interpret n as nodes and l as labels; then the arrow called
‘label’ takes a node to its label.
2. By deﬁnition, G is simple if and only if for any two distinct arrows f and g,
either source(f ) (cid:54)= source(g) or target(f ) (cid:54)= target(g). Since for any arrow x,

(cid:104)source, target(cid:105)(x) = (source(x), target(x))

G is simple if and only if for any two distinct arrows f and g,

(cid:104)source, target(cid:105)(f ) (cid:54)= (cid:104)source, target(cid:105)(g)

But that says that (cid:104)source, target(cid:105) is injective by deﬁnition.

Section 1.4

1. Let φ : G −→ H be a graph homomorphism with H simple. Let f : a −→ b be
an arrow of G . Then φ1(f ) has to be an arrow from φ0(a) to φ0(b). But there is at
most one such arrow because H is simple. Thus φ1(f ) is determined by φ0(a) and
φ0(b).
2. We must show that if u : m −→ n is an arrow of G , then

ψ1(φ1(u)) : ψ0(φ0(m)) −→ ψ0(φ0(n))
in K . Since φ is a graph homomorphism, φ1(u) : φ0(m) −→ φ0(n) in H . The
required equation then follows because ψ is a graph homomorphism.
3. a. Let h : c −→ d be an arrow in H . We must show that ψ1(h) : ψ0(c) −→ ψ0(d)
in G . Suppose ψ1(h) : a −→ b. Then, by deﬁnition of ψ and the fact that φ is a graph
homomorphism,

h = φ1(ψ1(h)) : φ0(a) −→ φ0(b)

in H . Thus φ0(a) = c and φ0(b) = d, so ψ0(c) = a and ψ0(d) = b as required.

Here is a second proof that ﬁts a pattern we use over and over in this book in
showing that if an invertible arrow has a certain property, then its inverse does too.

source(ψ1(h)) = ψ0(φ0(source(ψ1(h))))

= ψ0(source(φ1(ψ1(h)))) = ψ0(source(h))

and similarly for target.

b. By deﬁnition, we must prove the following equations:

ψ0 ◦ φ0 = (idG )0
ψ1 ◦ φ1 = (idG )1
φ0 ◦ ψ0 = (idH )0
φ1 ◦ ψ1 = (idH )1
For any graph F , (idF )0 = idF0 and (idF )1 = idF1 (see Example 1.4.3). The result
then follows from the fact that ψi = (φi)−1 for i = 1, 2.

Solutions for section 2.3

433

Solutions for Chapter 2

Section 2.1

1. Functional composition is associative, and the identity functions satisfy C–3 and
C–4, so it is only necessary to show that the identity functions are injective and
that composite of injective functions is injective. If S is a set and x, y ∈ S with
x (cid:54)= y, then idS(x) = x (cid:54)= y = idS(y), so idS is injective. Let f : S −→ T and g : T
−→ V . If x, y ∈ S and x (cid:54)= y, then f (x) (cid:54)= f (y) because f is injective. But then
g(f (x)) (cid:54)= g(f (y)) because g is injective. Hence g ◦ f is injective.

2. It is necessary to show that idS is surjective for each set S and that if f : S −→ T
and g : T −→ V are surjective then so is g ◦ f . If x ∈ S, then idS(x) = x so idS is
surjective. If v ∈ V , then there is a t ∈ T for which g(t) = v since g is surjective.
There is x ∈ S for which f (x) = t since f is surjective. Then g(f (x)) = v, so g ◦ f
is surjective.

3. Let α be a relation from A to B, β a relation from B to C and γ a relation
from C to D. By deﬁnition of composite, for x ∈ A and u ∈ D, (x, u) ∈ (γ ◦ β) ◦ α
if and only if there is an element y ∈ B for which (x, y) ∈ α and (y, u) ∈ γ ◦ β. But
(y, u) ∈ γ ◦ β if and only if there is z ∈ C such that (y, z) ∈ β and (z, u) ∈ γ. Thus
(x, u) ∈ (γ ◦ β) ◦ α if and only if there are elements y ∈ B and z ∈ C such that
(x, y) ∈ α, (y, z) ∈ β and (z, u) ∈ γ.

On the other hand, (x, u) is in γ ◦ (β ◦ α) if and only if there is z ∈ C such that
(x, z) ∈ β ◦ α and (z, u) ∈ γ. But (x, z) ∈ β ◦ α if and only if there is y ∈ B such that
(x, y) ∈ α and (y, z) ∈ β. Thus (x, u) ∈ γ ◦ (β ◦ α) if and only if there are y ∈ B and
z ∈ C such that (x, y) ∈ α, (y, z) ∈ β and (z, u) ∈ γ. Hence (γ ◦ β) ◦ α = γ ◦ (β ◦ α).

4. a. idA ◦ u = u by deﬁnition of idA, but idA ◦ u = idA by assumption. Hence
u = idA. This is an example of a useful heuristic: when a property is given in terms
of all arrows and you want to prove something about the property, see what it says
for identity arrows.

b. u ◦ idA = u by deﬁnition of idA, but u ◦ idA = idA by assumption. Hence

u = idA.

Section 2.2

1. This requires an arrow nonzero : NAT −→ BOOLEAN and the following equations:
nonzero ◦ 0 = false and nonzero ◦ succ = true. Since an arrow to NAT has to be
a composite ending in 0 or succ, this takes care of all possibilities.

Section 2.3

1. A must be empty or have only one element.

2. Composition is certainly a binary operation on Hom(A, A) since all the arrows
involved have the same source and target, so that every pair of arrows is composable.
It is associative by C–2 and idA is an identity by C–4.
3. If a semigroup S has two identity elements e and e(cid:48), then e = ee(cid:48) = e(cid:48). The ﬁrst
equation is true because e(cid:48) is an identity and the second one is true because e is an
identity.

434

Solutions for section 2.4

Section 2.4

1. a. If (S, α) is a set with relation, then idS : (S, α) −→ (S, α) is a homomorphism
and satisﬁes C–3 and C–4. We must show that the composite of homomorphisms is
a homomorphism; since they are set functions, C–1 and C–2 will follow. Suppose f :
(S, α) −→ (T, β) and g : (T, β) −→ (V, γ) are homomorphisms. If xαy, then f (x)βf (y)
because f is a homomorphism. Then g(f (x))γg(f (y)) since g is a homomorphism.
Hence g ◦ f is a homomorphism.

b. This is an immediate consequence of the deﬁnition of monotone in 2.4.2.

2. The identity functions are clearly continuous and strict (if relevant), so we need
only show that the composite of continuous functions is continuous and the com-
posite of strict functions is strict. Let f : S −→ T and g : T −→ V be continuous
functions. Let s be the supremum of a chain C = (c0, c1, c2, . . .) in S. Then the
image f (C ) = {f (ci) | i ∈ N} is a chain in T because a continuous function is
monotone. Moreover, f (s) is the supremum of f (C ). Since g is continuous, g(f (s))
is the supremum of g(f (C )), so that g ◦ f is continuous. Finally, if f and g are
strict, so is g ◦ f , since then g(f (D)) = g(D) = D.

3. The nonnegative integers form a chain in R+. There is no element in R+ satis-
fying SUP–1, since such an element would be a real number which is bigger than
any integer.

(cid:83)∞

4. Let C = (C0, C1, C2, . . .) be a chain in (P(S), ⊆). Let V be the union
i=1 Ci.
Then for every i, Ci ⊆ V , so SUP–1 is satisﬁed. Let Ci ⊆ W for every i and suppose
v ∈ V . Then v ∈ Ci for at least one i since V is the union of all the Ci. Thus v ∈ W ,
which proves that V ⊆ W so that SUP–2 holds. The bottom element is ∅.
5. Let S = Z ∪ {(cid:62), (cid:98)(cid:62)}, where (cid:62) and (cid:98)(cid:62) are distinct and are not integers. Let the
ordering ≤ on S be the usual ordering on Z, with (cid:62) ≤ (cid:98)(cid:62) and for any integer n,
n ≤ (cid:62) and n ≤ (cid:98)(cid:62). Then (S, ≤) is an ω-CPO. The function f : (S, ≤) −→ (S, ≤) for
which n (cid:55)→ n for n ∈ Z, (cid:62) (cid:55)→ (cid:98)(cid:62) and (cid:98)(cid:62) (cid:55)→ (cid:98)(cid:62) is monotone, but not continuous, since
it does not preserve the sup of the chain Z: that sup is (cid:62) but f ((cid:62)) = (cid:98)(cid:62).

6. For a partial function h, deﬁne ψ(h)(0) = 1, and require that ψ(h)(n) is deﬁned
if and only if h(n − 1) is deﬁned, and then ψ(h)(n) = 2 h(n − 1). Then the unique
ﬁxed point of ψ is g.

7. For a partial function h, deﬁne ψ(h) by requiring that ψ(h)(0) = ψ(h)(1) = 1
and that for n > 1, if h(n − 1) and h(n − 2) are deﬁned, then ψ(h)(n) is deﬁned
and ψ(h)(n) = h(n − 1) + h(n − 2). Then the Fibonacci function is the unique ﬁxed
point of ψ.

Section 2.5

1. Let f : S −→ T and g : T −→ V be semigroup homomorphisms. Then for any two
elements s, s(cid:48) ∈ S, g(f (s))g(f (s(cid:48))) = g(f (s)f (s(cid:48))) = g(f (ss(cid:48))), the ﬁrst equation
because g is a homomorphism and the second because f is a homomorphism. Thus
g ◦ f is a homomorphism.

In the monoid case, we also have g ◦ f (1) = g(f (1)) = g(1) = 1, so that again

g ◦ f is a homomorphism.

2. For m ∈ Zk, m = m + 0 = 0 · k + m, so m +k 0 = m and similarly 0 +k m = m.
To verify the associative law let m, n and p ∈ Zk. Deﬁne ri, qi, i = 1, 2, 3, 4 by

Solutions for section 2.6

435

m + n = q1k + r1
n + p = q2k + r2
r1 + p = q3k + r3
m + r2 = q4k + r4

and 0 ≤ ri < k for i = 1, 2, 3, 4. We must show that r3 = r4. It follows from the
equations just given that r3 − r4 = (q2 + q4 − q1 − q3)k. Since 0 ≤ ri < k for each
i, the diﬀerence r3 − r4 has to be between −k and k not inclusive. Since it is a
multiple of k, it must be 0; hence r3 = r4.

3. Call the function φ, so that for some q, n = qk + φ(n) and 0 ≤ φ(n) < k. Since
0 = 0 · k + 0, φ(0) = 0. For arbitrary m and n in Z, let q1 and q2 be the integers for
which m + n = q1k + φ(m + n) and φ(m) + φ(n) = q2k + φ(m) +k φ(n). Then

φ(m + n) − (φ(m) +k φ(n)) = (q1 − q2)k + (m − φ(m)) + (n − φ(n))

so that the left hand side of that equation is a multiple of k. Since it is the diﬀerence
of two numbers whose absolute values are less than k, the diﬀerence must be 0, so
that φ(m) +k φ(n) = φ(m + n).

4. It is easy to show that there is a one to one correspondence between homomorph-
isms φ from that ﬁrst monoid to any given monoid M and elements x ∈ M such
that x4 = 1. The correspondence takes such an element x to the homomorphism φ
which take the elements 0, 1, 2 and 3 to 1, x, x2 and x3, respectively. This clearly
preserves the identity and the equation φ(m + n) = φ(m)φ(n) is interesting only
when there is a carry mod 4, and in that case reduces to the requirement that
x4 = 1. A φ constructed this way is injective if and only if xn (cid:54)= 1 for n = 1, 2 or
3. The second monoid is easily seen to have two such elements with that property,
namely 2 and 3.

5. Since f ∗ is a homomorphism by 2.5.7, it is necessary by 2.5.5 only to show that it
is bijective. We are given that f is a bijection (isomorphisms in Set are bijections).
If a and a(cid:48) are lists in A∗ and they are diﬀerent, then they diﬀer in some coordinate;
i are diﬀerent. The ith coordinates of f ∗(a)
suppose the ith coordinates ai and a(cid:48)
and f ∗(a(cid:48)) are then f (ai) and f (a(cid:48)
i), which must be diﬀerent because f is injective.
Thus f ∗ is injective. If b is a list in B, let a be a list in A of the same length for
which f (ai) = bi for each coordinate i. There is such a list since f is surjective, and
then f ∗(a) = b, so f ∗ is surjective.

Section 2.6

1. C(M )op has exactly one object ∗ because C(M ) does. Deﬁne M op to be HomC(M )op(∗, ∗).
If x, y, z ∈ M and xy = z in M then yx = z in M op. Clearly C(M op) = C(M )op.

2. The ordering in all posets in this answer will be written ‘≤’. If P is a poset then
between any two objects in C(P )op there is at most one arrow because that is true
in C(P ). Thus C(P )op is the category determined by a poset called P op; x ≤ y in
P op if and only if y ≤ x in P .

436

Solutions for section 2.6

3. Let P be the set {1, 2} with discrete ordering (no two diﬀerent elements are
related). Let Q be the same set with the usual ordering (1 ≤ 2). Let R be the
set {1, 2, 3} with the discrete ordering. C(P ) is wide in C(Q) (they have the same
elements) but not full (1 ≤ 2 in Q but not in P ). C(P ) is full in C(R) because in
both x ≤ y holds only when x = y, but it is not wide since they do not have the
same elements.

4. Let M be the two-element monoid M = {1, e} with identity element 1 and ee = e.
Then in C(M ), the only object is ∗ and the arrows are 1 : ∗ −→ ∗ and e : ∗ −→ ∗.
Consider the category D with one object ∗ and one arrow e. Note that e is the
identity arrow for ∗ in D but not in C . D satisﬁes requirements S–1, S–2 and S–4
but not S–3. Note that D is even a category; it is just not a subcategory.

Section 2.7

1. We have f −1 ◦ g−1 ◦ g ◦ f = f −1 ◦ f = idA and similarly g ◦ f ◦ f −1 ◦ g−1 = idC.
Thus (g ◦ f )−1 = f −1 ◦ g−1 because the inverse is unique (2.7.3).

2. (a) Let P1 be the set {1, 2} with discrete ordering (no two diﬀerent elements are
op since x ≤ y if and only if x = y.
related). Then P1 = P1

(b) Let P2 be the same set with the usual ordering (1 ≤ 2). Then P2 (cid:54)= P2

op
op. However the map 1 (cid:55)→ 2, 2 (cid:55)→ 1 is an isomorphism

since 1 ≤ 2 in P2 but not in P2
op.
from P2 to P2

(c) Finally, let P3 = {{1}, {2}, {1, 2}} ordered by inclusion. Then P3 is not
op has no

op since P3 has an upper bound, namely {1, 2}, but P3

isomorphic to P3
upper bound.

3. First we construct a monoid M for which M (cid:54)= M op but M is isomorphic to M op:
let A = {x, y} and M = A∗. Then in M , (x)(y) = (x, y), while in M op, (x)(y) =
(y, x) so that M (cid:54)= M op. On the other hand the function φ : M −→ M op deﬁned by
φ(a1, . . . , an) = (an, . . . , a1) is easily seen to be an isomorphism of M with M op.

For a monoid M that is not isomorphic to M op, we use a construction that works
for any set S: The ‘right monoid’ generated by S is deﬁned on the set S ∪ {1} (1 is
some element not in S) by xy = y for x, y ∈ S and x1 = 1x = x for x ∈ S ∪{1}. M op
(the ‘left monoid’) is not isomorphic to M so long as S has two or more elements.

4. Let (P, ≤) and (Q, ≤) be posets and φ : P −→ Q an isomorphism. Suppose P
is totally ordered. Let q, q(cid:48) ∈ Q. Since P is totally ordered, we may assume (after
perhaps renaming) that φ−1(q) ≤ φ−1(q(cid:48)). Then q = φ(φ−1(q) ≤ φ(φ−1(q(cid:48)))) = q(cid:48)
so Q is totally ordered.

5. If x and y are isomorphic objects, then there is an arrow from x to y and one
from y to x (the isomorphism and its inverse). Then x ≤ y and y ≤ x, so x = y by
antisymmetry.

6. Let φ : S −→ T be an isomorphism of semigroups. Since it a set function with an
inverse, it is a bijection by Proposition 2.7.9. Conversely, suppose that φ : S −→ T
is a bijective homomorphism. Then its inverse is a homomorphism by 2.5.5.

Solutions for section 2.8

437

7. Suppose f satisﬁes (a). Then for any x, y ∈ A, f (x) = k(∗) = f (y). Conversely,
suppose f satisﬁes (b). If A = B = ∅, then (cid:104)(cid:105) = id∅ and we can take k = id∅ to get
f = id∅ = id∅ ◦ id∅. Otherwise, deﬁne an element b of B as follows. If A = ∅, let b
be any element of B. If not, let b be the element such that f (x) = f (y) = b for all
x, y ∈ A. Deﬁne k : 1 −→ A to be ∗ (cid:55)→ b where ∗ is the unique element of 1. Then
f = k ◦ (cid:104)(cid:105).

8. Let E be the graph with one node e and one arrow f : e −→ e. Let G be any
graph. Deﬁne φ : G −→ E by φ0(g) = e for any node g and φ1(u) = f for any arrow
f : g −→ h. Then φ1(u) : φ0(g) −→ φ0(h), so φ is a graph homomorphism. It is clearly
the only possible one.

9. Suppose f : S −→ S is an idempotent set function. Let x be an element of the
image, so there is some s ∈ S such that f (s) = x. Then f (x) = f (f (s)) = f (s) = x,
so x is a ﬁxed point. Conversely, if f (x) = x, then x is in the image of f by deﬁnition.
Conversely, suppose the image of f is the same as its set of ﬁxed points. Then

for any x ∈ S, f (f (x)) = f (x), so that f ◦ f = f .

10. a. Let f : A −→ A be an idempotent set function. Let B be the image of f
and g : A −→ B the corestriction of f . Let h : B −→ A be the inclusion of B in
A. Then for any x ∈ A, h(g(x)) = g(x) = f (x), so h ◦ g = f . And for any b ∈ B,
g(h(b)) = g(b) = f (b) = b by the result of the preceding problem, so g ◦ h = idB.

b. Let E be the category with one object ∗ and two arrows 1, e with 1 = id∗
and e ◦ e = e. There are no arrows g, h for which h ◦ g = e and g ◦ h = 1 since
in this category, composition is commutative. (Note that 1 is split. The identity is
split in any category.)

11. (i) is false. The category with two distinct objects and only identity arrows is
a counterexample.

(ii) is false. Take the category of the preceding example and add one arrow u

going from one of the objects, say A, to itself, with u ◦ u = idA.

(iii) is true. Suppose f : A −→ B is an arrow of C(P ). Its inverse goes from B
to A so A ≤ B and B ≤ A in P . Hence A = B. Since there is never more than one
arrow with the same source and target in C(P ), f must be idA.

Section 2.8

1. a. Let f : A −→ B be a monomorphism in C and let D be a subcategory of C .
Then if f ◦ g = f ◦ h in D the same equation is true in C , so that g = h in C .
Hence f is a monomorphism in D .

b. Let C be the full subcategory of Set determined by the sets A = {1} and
B = {1, 2}. Let k : B −→ A be the (only possible) function. Let D be the subcategory
of C consisting of idA, idB, and k. Then k is a monomorphism in D since there are
not two distinct arrows from B to B, but it is not a monomorphism in C since k
composed with any of the four functions from B to B gives k again.

2. Suppose (g ◦ f ) ◦ x = (g ◦ f ) ◦ y. Then g ◦ (f ◦ x) = g ◦ (f ◦ y). Because g is a
monomorphism, f ◦ x = f ◦ y. Then x = y as required because f if a monomorph-
ism.

438

Solutions for section 2.8

3. This happens in Set. Let f to f be the inclusion of {1, 2} into {1, 2, 3} and
g : {1, 2, 3} −→ {1, 2} be 1 (cid:55)→ 1, 2 (cid:55)→ 2, 3 (cid:55)→ 2. Then g ◦ f (which is id{1,2}) is monic
but g is not.

4. In this answer we use these facts repeatedly:

(a) An isomorphism in the category of sets is a bijection and conversely.

(b) If i : X −→ S and j : Y −→ S are injective functions and β : X −→ Y is a

bijection for which j ◦ β = i then i ◦ β−1 = j.

(a)(i) Let s = m(a) be in the image of m and let β : A −→ B be the bijection for
which m = n ◦ β. Then s = n(β(a)) so s is in the image of n. A symmetric argument
using β−1 shows that the image of n is included in the image of m, so the images
are equal.

(a)(ii) Let m : A −→ S be an injection in O. Deﬁne β : A −→ I to be the core-
striction of m to I. β is injective because m is and surjective because I is the image
of m. Hence it is bijective. Clearly i ◦ β = m.

(a)(iii) Let β : J −→ I be the bijection for which i ◦ β = j. Since i and j are
both inclusions, for any x ∈ J, i(x) = x = j(x) = i(β(x)), so i ◦ β = i. Since i is
injective, β(x) = x for all x ∈ J. Since β is surjective, I = J and β = idI .

(a)(iv) Immediate from (i), (ii) and (iii).
(b)(i) Immediate from the deﬁnition of subobject.
(b)(ii) Immediate from properties of equivalence relations.
(b)(iii) Immediate from (i) and (ii).

5. We must ﬁnd arrows k : D −→ C and k(cid:48) : C −→ D such that idD = h ◦ k and
h = idD ◦ k(cid:48). These requirements are satisﬁed by k = h−1 and k(cid:48) = h.

6. Let m : C −→ 0 be a monomorphism into an initial object. By Proposition 2.8.7,
m is an isomorphism. By Problem 5, it is equivalent to id0, so that the subobject
it inhabits is not proper by deﬁnition of proper.

7. Let m : A −→ 1 be monic and let f , g : B −→ A. Then m ◦ f = m ◦ g : B −→ 1 by
deﬁnition of terminal object, and m is monic, so f = g. In particular, for any arrow
h : A −→ C, h ◦ f = h ◦ g implies that f = g; hence h is monic.

8. a. The terminal object is a one-element set. By the remarks in 2.8.12, such a
set has two subobjects because it has two subsets: the set itself and the empty set.
(Note in connection with the preceding exercise that there is at most one function
from any set B to the empty set: none at all if B is nonempty, and the identity
function if B is empty.)

b. The terminal graph has one node and one arrow. It has three subgraphs: itself,
the graph with one node and no arrows, and the graph with no nodes or arrows.
These are in one to one correspondence with the subobjects.

c. The terminal monoid is the monoid with one element. It has only itself as a

submonoid.

Solutions for section 2.9

439

9. A relation M : A −→ B is a monomorphism in Rel if and only if the following
condition holds: for any two subsets U and V of A, if U and V have the same images
under M , then U = V . (In other words, the induced function from PA to PB is
injective.) The image of U under M is the set b∃a ∈ U (aM b); we will denote it by
U M .

To prove this, ﬁrst suppose M satisﬁes the condition and suppose R, S : C
−→ A are relations such that M ◦ R = M ◦ S. For any c, the images c(M ◦ R) and
c(M ◦ S) are the same, so the sets cR and cS have the same image under M . By
the condition, cR = cS. But that is for every c, which implies that R = S.

Suppose M does not satisfy the condition. Let U and V be diﬀerent subsets of
A with the same image under M . Deﬁne relations R, S : {1} −→ A by 1Ra ≡ a ∈ U
and 1Sa ≡ a ∈ V . Then 1R = U and 1S = V , and U and V have the same images
under M , so M ◦ R = M ◦ S.

Section 2.9

1. Let f : S −→ T be a surjective monoid homomorphism and let g, h : T −→ V
be monoid homomorphisms. Suppose that g ◦ f = h ◦ f . Let t be any element of
T . Then there is an element x ∈ S for which f (x) = t. Then g(t) = g(f (x)) =
h(f (x)) = h(t). Since t was arbitrary, g = h so f is an epimorphism.

2. That φ is a homomorphism requires verifying that φ(0) = 0 (which is true by
deﬁnition) and that φ(m +4 n) = φ(m) +2 φ(n) for all m, n ∈ Z4: for example,
φ(2 +4 3) = φ(1) = 1 and φ(2) +2 φ(3) = 0 +2 1 = 1. (The comments in the answer
to Exercise 4 of Section 2.5 apply here too.) It is surjective since it has both 0 and
1 as values.

Now suppose ψ : Z2 −→ Z4 is a monoid homomorphism satisfying φ ◦ ψ = idZ2
.
Since ψ(0) = 0 necessarily, there are only four possibilities for ψ, determined by
what it does to 1. If ψ(1) = 0 then φ(ψ(1)) = φ(0) = 0 (cid:54)= 1. If ψ(1) = 1 then
ψ(1+2 1) = ψ(0) = 0 but ψ(1)+4 ψ(1) = 2, so ψ is not a homomorphism. If ψ(1) = 2
then φ(ψ(1)) (cid:54)= 1. Finally, if ψ(1) = 3, then again ψ is not a homomorphism because
ψ(1 +2 1) = 0 (cid:54)= 2 = ψ(1) +4 ψ(1).

3. a. The statement that m ∈ M is a monomorphism says that mn = mp implies
n = p (m is left cancellable). That it is an epimorphism says that nm = pm implies
n = p (m is right cancellable) If m is an isomorphism then m is a monomorphism
and an epimorphism by Proposition 2.9.10. To see the converse, let m be a mono-
morphism. Let M = {m1, m2, . . . , mk} be ﬁnite. The elements mm1, mm2, . . . , mmk
are all diﬀerent, so there are k of them, so one of them, call it mn, is 1. But then
mnm = m = m · 1 and m is a monomorphism, so nm = 1. Hence m is an isomorph-
ism. A symmetric argument shows that an epimorphism is an isomorphism.

Warning: In a ﬁnite semigroup, a left cancellable element need not be right

cancellable.

b. Every nonzero element of the nonnegative integers with addition as operation
is both a monomorphism and an epimorphism but not an isomorphism. (In other
words, m + n = m + p implies n = p and similarly on the other side, but if m (cid:54)= 0
then m has no inverse.)

4. If f : A −→ B has a splitting g : B −→ A, then in P , A ≤ B and B ≤ A so A = B.
The only arrow from A to itself is idA.

440

Solutions for section 2.9

5. h ◦ g is an idempotent because h ◦ g ◦ h ◦ g = h ◦ id ◦ g = h ◦ g. It is split
because h and g ﬁt the requirements for the h and g of the deﬁnition in the exercise
mentioned: h ◦ g = h ◦ g and g ◦ h = id.

6. (i) Hom(A, f )(g) = Hom(A, f )(h) if and only if f ◦ g = f ◦ h by deﬁnition of
Hom(A, f ). The result is the immediate from the deﬁnitions of injective and mono-
morphism.

(ii) Hom(f, D)(u) = Hom(f, D)(v) if and only if u ◦ f = v ◦ f . Again, the result

follows from the deﬁnition of injective and epimorphism.

(iii) Suppose f is a split monomorphism with splitting g, so g ◦ f = idB. Suppose
u : B −→ D. Then Hom(f, D)(u ◦ g) = u ◦ g ◦ f = u, so Hom(f, D) is surjective.
Conversely suppose Hom(f, D) is surjective for every object D. Then there is a
g : C −→ B such that hom(f, B)(g) = idB; that is, g ◦ f = idB, so f is split.

(iv) Suppose f is a split epimorphism, with f ◦ g = idC. Let u : A −→ C. Then
we have Hom(A, f )(g ◦ u) = f ◦ g ◦ u = u so Hom(A, f ) is surjective. Conversely,
suppose Hom(A, f ) is surjective for every A. Let g : C −→ B satisfy Hom(B, f )(g) =
idC, that is, f ◦ g = idC, so f is a split epimorphism.

(v) An isomorphism is a split epimorphism and a split monomorphism because
it is split by its inverse. Thus an isomorphism satisﬁes (a) and (b). In particular
an isomorphism is an epimorphism and a monomorphism. It then follows from (i)
through (iv) that an isomorphism satisﬁes (c) and (d). Conversely, suppose f is a
split epi, split by g : C −→ B, so f ◦ g = idC. Then f ◦ g ◦ f = f = f ◦ idB. If f is
also mono then g ◦ f = idB. Hence (a) implies that f is an isomorphism. That also
follows from (b) by doing the same proof in the opposite category (note that the
dual of the concept of isomorphism is isomorphism). Finally, (c) implies (a) by (i)
and (iv) and (d) implies (b) by (ii) and (iii).

7. (i) Suppose an arrow x : m −→ n in H is not in the image of f1. Let U be
the graph with one node a and two arrows u, v : a −→ a. Let g : H −→ U take all
nodes to a and all arrows to u, and let h take all nodes to a and all arrows except
x to u, with h(x) = v. Both g and h are graph homomorphisms. Then g ◦ f = h ◦ f
but g (cid:54)= h, showing that f is not epi.

If all the arrows of H are in the image of f1 but there is a node n not in the
image of f0, then there can be no arrows with n as source or target. Let V be the
graph with two nodes a and b and one arrow u : a −→ a. Let g : H −→ V take all
nodes to a and all arrows to u; let h : H −→ V take all nodes except n to a, n
to b and all arrows to u. Again, g and h are graph homomorphisms and g (cid:54)= h but
g ◦ f = h ◦ f .

Conversely, suppose that f0 and f1 are both surjective. Let g, h : H −→ K
satisfy g ◦ f = h ◦ f . Then for every node or arrow x of H there is a node or arrow
m of G for which fi(m) = x (i = 0 if x is a node, i = 1 if x is an arrow). Then
gi(x) = gi(fi(m)) = hi(fi(m)) = hi(x), so g = h and f is epi.

(ii) Suppose f is monic and suppose u and v are arrows of G for which f1(u) =
f1(v). Let F denote the graph with two nodes a and b and one arrow x : a −→ b,
and deﬁne g : F −→ G to take x to u and h : F −→ G to take x to v. What g and h
do on nodes is then forced. Then f ◦ g = f ◦ h but g (cid:54)= h, so f is not monic. If f is
monic and f1 is injective but there are nodes m and n of G for which f0(m) = f0(n),
then we carry out the same trick except that we take F to be the graph with one
node and no arrows and let g and h take that node to m and n respectively.

Solutions for section 2.10

441

Conversely, suppose f0 and f1 are injective. Suppose g : F −→ G and h : F
−→ G are graph homomorphisms such that f ◦ g = f ◦ h. Let x be any node or
arrow of F . Then fi(gi(x)) = fi(hi(x)) (i = 0 if x is a node, i = 1 if x is an arrow),
so because fi is injective, gi(x) = hi(x). Hence g = h so f is monic.

(iii) This is an immediate consequence of Exercise 3 of Section 1.4 and the fact

that an isomorphism in the category of sets is a bijection.

8. a. Let f : A −→ B, g : B −→ A, f ◦ g = idB, so that f is split by g. Suppose that
f = m ◦ h with m monic. We have m ◦ h ◦ g = f ◦ g = idB. Hence m ◦ h ◦ g ◦ m =
m, so h ◦ g ◦ m = idA since m is monic. Hence m is an isomorphism with inverse
h ◦ g.

b. In C , if f is an epimorphism and f = m ◦ h with m monic, then m is epic by

Proposition 2.9.4. Hence by the assumption, m is an isomorphism.

Section 2.10

1. FS–1: The requirement that M ◦ I ⊆ M follows from the Shoe-Sock Theorem
(Exercise 1 of Section 2.7) and I ◦ E ⊆ E because arrows are closed under compo-
sition. FS–2: If f : A −→ B is an arrow, then f = idB ◦ f , and idB is an isomorphism.
FS–3: Given the commutative square

A

B(cid:45)(cid:45)e

f

g

(cid:63)
(cid:45)
C

(cid:63)
D(cid:45)

m
with e ∈ E and m ∈ M , let h = m−1 ◦ g. Then because the square commutes,
h ◦ e = m−1 ◦ g ◦ e = m−1 ◦ m ◦ f = f , and m ◦ h = m ◦ m−1 ◦ g = g.
2. Suppose that every arrow in M is monic and that

A

B(cid:45)(cid:45)e

f

g

m
is commutative. Suppose that h : B −→ C, h(cid:48) : B −→ C satisfy m ◦ h = m ◦ h(cid:48) = g.
Then h = h(cid:48) becuase m is monic. The other proof is dual.

(cid:63)
(cid:45)
C

(cid:63)
D(cid:45)

3. Every isomorphism in Set is a bijection, hence an epimorphism and a mono-
morphism by Theorems 2.8.3 and 2.9.2. Given an arrow f : A −→ B, let C denote
the image of f , e : A −→ C the corestriction of f to C, and i : C −→ B the inclusion.
Then f = i ◦ e. Finally, suppose that

A

B(cid:45)(cid:45)e

f

g

(cid:63)
(cid:45)
C

(cid:63)
D(cid:45)

m

442

Solutions for section 3.1

is a commutative square with e ∈ E and m ∈ M . Deﬁne h : B −→ C as follows:
If b ∈ B, then there is a ∈ A for which e(a) = b since e is surjective. Let h(b) =
f (a). We must show that this is well deﬁned, that is, that if e(a) = e(a(cid:48)) = b then
f (a) = f (a(cid:48)). Suppose that e(a) = e(a(cid:48)) = b. Then m(f (a)) = g(e(a)) = g(e(a(cid:48))) =
m(f (a(cid:48))) because the square commutes, so f (a) = f (a(cid:48)) since m is monic. Finally,
we must show that h ◦ e = f and m ◦ h = g. The ﬁrst is by deﬁnition. As for the
second, we have m ◦ h ◦ e = g ◦ e = m ◦ f = m ◦ h ◦ e, so m ◦ h = g because e is an
epimorphism.

4. If h : Z −→ N were a diagonal ﬁll-in, then we must have i(h(−1)) = −1, but −1
is not in the image of i.

Solutions for Chapter 3

Section 3.1

1. Since functors preserve the operations of domain and codomain, the fact that
g ◦ f is deﬁned implies that the domain of g is the codomain of f . But then the
domain of F1(g), which is F0 applied to the domain of g, is the same as the codomain
of F1(f ). Hence F1(g) ◦ F1(f ) is deﬁned in D .
2. The initial category has no objects and, therefore, no arrows. It clearly has
exactly one functor to every other category. The terminal category has just one
object and the identity arrow of that object. To any category C there is just one
functor that takes every object to that single object and every arrow to that one
arrow.

3. If f : A −→ B is a function between sets, the existential powerset functor takes
f to f∗ deﬁned by f∗(A0) = {f (a) | a ∈ A0}. If g : B −→ C, then c ∈ (g∗ ◦ f∗)(A0)
if and only if there is an a ∈ A0 such that c = g(f (a)). This is the same condition
that c ∈ (g ◦ f )∗(A0). It is evident that when f is the identity, so is f∗.

The universal powerset functor f! is deﬁned by b ∈ f!(A0) if and only if b = f (a)
implies that a ∈ A0. If f is the identity, then b = f (a) if and only if b = a so that
f!(A0) = A0 (the identity arrow). If f : A −→ B and g : B −→ C, then c ∈ (g! ◦
f!)(A0) if and only if c = g(b) implies that b ∈ f!(A0), which is true if and only if
b = f (a) implies a ∈ A0. Putting these together, we see that c ∈ (g! ◦ f!)(A0) if and
only if c = f (g(a)) implies a ∈ A0. But this is the condition that c ∈ (g ◦ f )!(A0).

4. a. Since a functor is determined by its value on objects and arrows, a functor
that is injective on objects and arrows is certainly a monomorphism. (Compare
Exercise 7 of Section 2.9.) The other way is less obvious. If F is not injective on
objects, say C (cid:54)= C (cid:48) but F (C) = F (C (cid:48)) then let 1 be the category with one object
and only the identity arrow. Let G : 1 −→ C take that object to C, while G(cid:48) : 1
−→ C takes it to C (cid:48). Then G (cid:54)= G(cid:48), while F ◦ G = F ◦ G(cid:48), whence F is not a
monomorphism. Next suppose F is injective on objects, but not on arrows. If f (cid:54)= g
are two arrows with F (f ) = F (g), then F (f ) and F (g) have the same domain and
the same codomain. Since F is injective on objects, it must be that f and g have
the same domain and the same codomain. Say that f, g : C −→ C (cid:48). Now let 2 be the
category with two objects and one nonidentity arrow between them:

0 −→ 1

Solutions for section 3.1

443

Let G : 2 −→ C take 0 to C, 1 to C (cid:48) and the nonidentity arrow to f , while G(cid:48) is
the same on objects, but takes the nonidentity arrow to g. Clearly G (cid:54)= G(cid:48), while
F ◦ G = F ◦ G(cid:48).

b. The functor simply forgets the existence of the identity element. Two distinct
monoids must diﬀer in either their sets of elements or multiplication and in either
case must diﬀer as semigroups. Thus the functor is injective on objects. For similar
reasons, it is injective on arrows. We have just seen that a functor that is injective
on objects and arrows is a monomorphism.

5. a. It being evident that e is a two-sided identity, it is necessary only to show
that the multiplication is associative. In any equation x(yz) = (xy)z as soon as any
of the variables is e, both sides reduce to a binary product of the remaining two
terms (one or both of which might also be e). If none of them is e, then this is an
equation involving terms from S and so is valid because it is in S.

b. If we denote by eS and eT the elements added to S and T respectively, then

we deﬁne F (f ) = f 1 : S1 −→ T 1 by

(cid:189)

f 1(x) =

f (x)
eT

if x ∈ S
if x = eS

In verifying that f 1(xy) = f 1(x)f 1(y) it is necessary to consider cases. If neither x
nor y is eS, then it follows from the fact that f is a homomorphism of semigroups.
If, say, x = eS, then both sides reduce to f 1(y) and similarly if y = eS. Finally, we
must show that F is a functor. It is clear that if f : S −→ S is the identity, then
f 1 : S1 −→ S1 is the identity as well. It is also clear that if g : T −→ R is another
monoid homomorphism, then

(cid:189)

(g1 ◦ f 1)(x) =

(g ◦ f )(x)
eR

if x ∈ S
if x = eS

= (g ◦ f )1(x)

c. Since F is injective on objects and arrows, it is a monomorphism (see preceding

exercise).

6. Deﬁne α : HomMon(F (A), M ) −→ HomSet(A, U (M )) by α(g)(a) = g(a). The fact
that (α(β(f )))(a) = f (a) is clear. On the other hand, if g : F (A) −→ M is a monoid
homomorphism, then

(β(α(g)))(a1, a2, · · · , an) = α(g)(a1)α(g)(a2) · · · α(g)(an)

= g(a1)g(a2) · · · g(an) = g(a1, a2, · · · , an)

the last equality coming from the fact that g is a monoid homomorphism. Thus β
is invertible and hence bijective.
7. In Exercise 5, we showed that γ(h) (which would have been called h1 there) is a
monoid homomorphism. To see that γ is a bijection, we deﬁne

δ : HomMon(F (S), M ) −→ HomSem(S, U (M ))

by δ(g)(x) = g(x) for x ∈ S. Since a monoid homomorphism is also a semigroup
homomorphism, this is well deﬁned. Clearly δ(γ(h))(x) = h(x) for x ∈ S and h : S
−→ U (M ). To go the other way, suppose g : F (S) −→ M . For x ∈ S, γ(δ(g))(x) =
δ(g)(x) = g(x). For eS, we have γ(δ(g))(eS) = 1 by deﬁnition of γ, but g(eS) = 1
since g is a monoid homomorphism. Thus δ = γ−1 and γ is a bijection.

444

Solutions for section 3.1

8. This is an immediate consequence of Exercises 4.b and 5.c.

9. It is obvious that Set is a subcategory of the category of partial functions. To
get a functor in the other direction, let F (S) = S ∪ {S}. If f : S −→ T is a partial
function, let F (f ) : F (S) −→ F (T ) be the total function deﬁned by

(cid:189)

F (f )(x) =

f (x)
T

if x ∈ S and f (x) is deﬁned
if x = S or f is not deﬁned at x

It is clear that if f (cid:54)= g, then F (f ) (cid:54)= F (g).

10. On the one hand, if A is discrete, for any function F0 : A0 −→ B0 there is a
unique functor F : A −→ B whose value at the identity of some object A of A is
the identity of F0(A). To go the other way, suppose A is not discrete. Suppose ﬁrst
that there is an arrow f : A −→ B in A with A (cid:54)= B. Let B be the category with
the same objects as A , but with no nonidentity arrows. Then the identity function
F0 : A0 −→ B0 cannot be extended to a functor since there is nowhere to send f .
Now suppose that all arrows of A are endoarrows. Let B have the same objects as
A and let

HomB(A, A) = HomA (A, A) × HomA (A, A)
for an object A of A . The identity function F0 : A0 −→ B0 can be extended in at
least two ways to a functor. The ﬁrst way is to take F (f ) = (f, idA) for f : A −→ A
in A and the second is F (cid:48)(f ) = (idA, f ).

11. We claim that a category is indiscrete if and only if there is exactly one arrow
between any two objects. It is obvious that such a category is indiscrete. To go the
other way, ﬁrst suppose that A has two objects A and B with no arrows between
them, then A cannot be indiscrete. For if 2 denotes the category with two objects
0 and 1 and one arrow between them, then the object function that takes 0 to A
and 1 to B cannot be extended. If there is more than one arrow from A to B, then
the same object function on 2 has more than one extension to a functor.

Section 3.2

1. If M acts on S, let φ : M −→ F T (S) be deﬁned by φ(a)(x) = ax for a ∈ M and
x ∈ S. We have φ(1)(a) = 1a = a = id(a) so that φ(1) = id. Also, for a, b ∈ M ,

φ(ab)(x) = (ab)x = a(bx) = φ(a)(φ(b)(a))

so that φ(ab) = φ(a) ◦ φ(b). Conversely, if φ : M −→ F T (S), then let M act on S by
letting ax = φ(a)(x). The computations above can be reversed to show that since φ
is a monoid homomorphism, the M -set identities are satisﬁed. It is clear that these
processes are inverse to each other.

Solutions for section 3.3

445

Section 3.3

1. a. Since a functor is faithful if it is injective between hom sets and a monoid has
only one hom set, such a functor is faithful if and only if it is injective.

b. Since hom sets are either singleton or empty and a function on such a set is

always injective, such a functor is always faithful.

2. A functor is full if it is surjective on hom sets so a functor between monoids is
full if and only if it is surjective. As for posets, a functor f : P −→ Q between posets
is full if and only if whenever f (x) ≤ f (y), then x ≤ y.

3. No. For example let (N, +) and (N, ∗) denote the monoids of integers with
the operations of addition and multiplication, respectively. The function f : (N, +)
−→ (N, ∗) that is constantly 0 is a semigroup homomorphism that is not a monoid
homomorphism since it does not preserve the identity.

4. It is faithful, but not full. Certainly, if f (cid:54)= g : S −→ T , then F (f ) (cid:54)= F (g) : S∗
−→ T ∗ since on strings of length 1, F (f ) is essentially the same as f . On the other
hand, there are inﬁnitely many homomorphisms from N = F (1) to itself (take the
generating element to any power of itself), but only one function from {1} to itself.

5. It is faithful because f can be recovered from P(f ) by its actions on singletons.
On the other hand, it cannot be full since, for example, there is only one function
from 1 to 1 and four from P(1) to P(1).

6. The isomorphism is the functor from Rel op to Rel that takes every object to
itself and every relation R ⊆ A × B from A to B in Rel (hence from B to A in
Rel op) to the relation Rop = {(b, a) | (a, b ∈ R}. The inverse functor is this same
functor considered as going from Rel to Rel op.

7. Let G be a groupoid. The isomorphism F : G op −→ G is the function that takes
objects to themselves and an arrow f : X −→ Y in G (hence f : Y −→ X in G op) to
f −1 : Y −→ X in G . F preserves composition by the Shoe-Sock Theorem (Exercise 1,
page 45.) Since F (F (f )) = (f −1)−1 = f (see 2.7.3), it follows that F : G op −→ G is
the inverse of F : G −→ G op, so that F is an isomorphism.

8. A functor from a monoid to a category takes the single object of the monoid
to some object of the category and is a monoid homomorphism from the monoid
to the monoid of endoarrows of that object. In other words, its arrow part is a
monoid homomorphism. Therefore, if i : N −→ Z is the inclusion, the nonexistence
of monoid homomorphisms g (cid:54)= h such that g ◦ i = h ◦ i implies that there also
cannot exist functors with that property.

9. Suppose f : A −→ B is a split mono in a category. Then there is a g : B −→ A
with g ◦ f = idA. For any functor F , F (g) ◦ F (f ) = F (g ◦ f ) = F (idA) = idF (A),
since functors preserve composition and identities. The argument for split epis is
dual.

10. a. There is exactly one semigroup structure on the empty set and also on the
one point set and these are the initial, respectively terminal semigroups. Thus the
underlying functor preserves and reﬂects both initial and terminal objects.

b. There is exactly one category structure on the empty graph and that is the
initial category, so the underlying functor preserves and reﬂects the initial object.

446

Solutions for section 3.3

The terminal category has one object and one arrow, the identity. This is the unique
category structure on the graph with one object and one arrow and that is the
terminal graph. Thus the terminal object is also preserved and reﬂected.

11. T is a terminal object if and only if there is exactly one arrow from any object
to T . In particular, Hom(A, T ) is a singleton set, which is a terminal object in Set.

12. Let F : C /B −→ (C /A)/f send u : C −→ B to u : f ◦ u −→ f as suggested. If
v : D −→ B is another object of C /B and g : u −→ v is an arrow (which is to say that
v ◦ g = u), then f ◦ v ◦ g = f ◦ u so that we can simply let F (g : u −→ v) = g : F (u)
−→ F (v). Let G : (C /A)/f −→ C /B take an object w : (g : C −→ A) −→ f to w : C
−→ B. Suppose w(cid:48) : g(cid:48) −→ f is also an arrow of C /A (hence an object of (C /A)/f )
and x : w(cid:48) −→ w is an arrow of (C /A)/f . Then by deﬁnition of arrow in a slice
category, w ◦ x = w(cid:48) : g(cid:48) −→ f in C /A, hence in C . Thus we can set G(x : w(cid:48)
−→ w) = x : dom(w(cid:48)) −→ dom(w). It is straightforward to check that F and G are
functors. It is clear that they are inverse to each other.

Section 3.4

1. Let F : C −→ D be an isomorphism with inverse G. Then G is a pseudo-inverse
for F . We deﬁne the arrows uC required by E–2 to be idC for each object C, and
similarly vC = idC. Since G(F (f )) = f and F (G(g)) = g for all arrows f of C and
g of D , requirements E–2 and E–3 are satisﬁed.

2. Deﬁne F : Pfn −→ Pts by F (S) = (S ∪ {S}, S). S is chosen as the additional
element to guarantee that it is not already an element of S. If f : S −→ T is a partial
function, let F (f ) be deﬁned by

(cid:110)

F (f )(x) =

f (x)
T

if x ∈ S and f is deﬁned at x
otherwise

It is obvious that F preserves identities. As for composition, if g : T −→ R is a partial
function, then g(f (x)) is deﬁned if and only if f is deﬁned at x and g is deﬁned at
f (x), which is exactly when g ◦ f is deﬁned at x. From this, it is immediate that F
preserves composition.

We deﬁne a pseudo-inverse G : Pts −→ Pfn by G(S, s) = S − {s} and if f : (S, s)

−→ (T, t) is an arrow, then

(cid:189)

G(f )(x) =

f (x)
if f (x) (cid:54)= t
undeﬁned if f (x) = t

It is easy to show that G is a functor. Now if S is a set, it is clear that G(F (S)) = S
and (S, s) ∼= F (G(S, s)) by an isomorphism vS which is the identity on S and takes
s to S (the latter being the added element of F (S − {s})). What has to be shown
is that for any partial function f : S −→ T and any function g : (S, s) −→ (T, t), E–2
and E–3 hold. These are a simple matter of considering cases and we omit them.

3. Let P be the category of preordered sets and Q the category of small categories
as described. We let F : P −→ Q take a preordered set (P, ≤) to the category
C(P, ≤) as described in 2.3.1. If f : P −→ P (cid:48) is a monotone function, then F (f )
agrees with f on objects and when a ≤ b, then we let F (f )(b, a) = (f (b), f (a)). In

Solutions for section 3.5

447

the other direction, let Q be a category in Q and let G(Q) be the preordered set
whose elements are the objects of Q with the preorder that a ≤ b if there is an
arrow a −→ b. The composition law in the category makes this relation transitive
and the identity makes it reﬂexive. If f : Q −→ Q(cid:48) is a functor in Q, let G(f ) be the
object function of f . G(f ) is monotone because if x ≤ y in Q then f must take the
corresponding arrow to an arrow in Q(cid:48). It is clear that G ◦ F is the identity, so that
E–2 is satisﬁed with uC = idC. F ◦ G is the identity on the objects and that there
will be an arrow a −→ b in Q if and only if a ≤ b in G(Q) if and only if there is an
arrow a −→ b in F (G(Q)). Thus there is an isomorphism vC : Q −→ F (G(Q)) which
is the identity on objects and which takes an arrow a −→ b in Q to (the only) arrow
a −→ b in F (G(Q)). These isomorphisms must satisfy E–3 because for any arrow g
there is only one arrow that vD(cid:48) ◦ g ◦ v−1
4. There is an functor F : M −→ L that takes n to the space of n-rowed column
vectors and a matrix A : m −→ n to the linear transformation of multiplying on the
left by A. In case one of the numbers is 0, there is only the 0 linear transformation
between them. It is well known that this is a functor (matrix multiplication corre-
sponds to composition of linear transformations) which is full and faithful and that
every ﬁnite dimensional vector space is isomorphic to a space of column vectors. A
pseudo-inverse G is found by choosing, for each space V , a basis B and then letting
G(V ) be the number of elements of B. If V (cid:48) is another space with chosen basis
B(cid:48) and T : V −→ V (cid:48) is a linear transformation, then G(T ) is the matrix of T with
respect to B and B(cid:48). Although G is uniquely deﬁned on objects, its value on arrows
depends completely on the choice, for each vector space V , of a basis for that space.
In this case um is the m × m identity matrix, so E–2 is satisﬁed, and E–3 follows
from the deﬁnition of the linear transformation determined by a matrix, given a
basis.

D can be.

5. a. Let F : Mon −→ Ooc take the monoid M to the category with one object
and with M as its set of endoarrows. If f : M −→ N is a monoid homomorphism,
then F (f )(M ) = N on the object and F (f )(a) = f (a) for a ∈ M . It is immediate
that F is a functor. Let G : Ooc −→ Mon take the one-object category C to the
object of endomorphisms of that single object. It is clear that G ◦ F is the identity,
so E–2 holds. F ◦ G is the identity on the arrows of the category and is evidently
the only possible isomorphism on the singleton set of objects, so E–3 holds because
there is no choice possible for the arrow.

b. Suppose f, g : M −→ N are homomorphisms of monoids. Then since F (f )
agrees with f on the arrows of F (M ), F (f ) = F (g) implies f = g. This shows
directly that F is faithful. To see it is full, let h : F (M ) −→ F (N ) be a functor.
Then the arrow function of h is a monoid homomorphism f from the monoid of
endomorphisms of the object of F (M ) to the object of F (N ). F (f ) agrees with h
on arrows and certainly does on objects since there is no choice.

Section 3.5

1. Suppose that both CR–1 and CR–2 of 3.5.1 are satisﬁed. Then special cases
result from letting h or k be an identity. Using these special cases, we have that

g1 ◦ f1 ∼ g2 ◦ f1 ∼ g2 ◦ f2

448

Solutions for section 3.5

On the other hand, special cases of the diagram here result by setting f1 = f2
or g1 = g2. Using them, we have that f ∼ g implies that k ◦ f ∼ k ◦ g and that
f ◦ g ∼ f ◦ h.

2. Suppose that ∼1 and ∼2 are congruences. The intersection of two equivalence
relations is an equivalence relation on any set. Also if f1 ∼1 f2 and g1 ∼1 g2 implies
that f1 ◦ g1 ∼1 f2 ◦ g2 and if f1 ∼2 f2 and g1 ∼2 g2 implies that f1 ◦ g1 ∼2 f2 ◦ g2,
then for ∼ = ∼1 ∩ ∼2, f1 ∼ f2 and g1 ∼ g2 imply that f1 ◦ g1 ∼ f2 ◦ g2.

3. A functor F is full if every arrow in Hom(F (A), F (B)) has the form F (f ) for some
f : A −→ B. A quotient as described here is surjective on arrows, so the condition
of fullness is certainly satisﬁed.

4. a. It is an equivalence because F (f ) = F (f ), F (f ) = F (g) implies F (g) = F (f )
and F (f ) = F (g) and F (g) = F (h) implies F (f ) = F (h). To see that it is a con-
gruence, suppose F (f1) = F (f2) and F (g1) = F (g2). Then

F (f1 ◦ g1) = F (f1) ◦ F (g1) = F (f2) ◦ F (g2) = F (f2 ◦ g2)

The result follows from Exercise 1.

b. Suppose [f ], [g] : A −→ B are arrows of C /∼ such that F0([f ]) = F0([g]). Then

F (f ) = F (g), whence f ∼ g and [f ] = [g].

c. F = F0 ◦ Q and we just seen that F0 is faithful and that Q is full (previous

exercise).

5. It follows from 2.2.5(ii) that ¬ true = false and ¬ false = true. Thus

(cid:98)F (¬ true) = (cid:98)F (false)

and

(cid:98)F (¬ false) = (cid:98)F (true)

Similarly, (cid:98)F (chr ◦ ord) = id. Thus f ∼ g implies (cid:98)F (f ) = (cid:98)F (g) for the generators
of the congruence. The set of pairs {(f, g)} for which (cid:98)F (f ) = (cid:98)F (g) thus includes
the generators and is closed under composition since functors preserve composition.
Thus it includes all pairs for which f ∼ g.

6. a. Such a relation satisﬁes Deﬁnition 3.5.1(a) automatically, since all elements of
M are arrows of C(M ) with the same domain and codomain. The deﬁnition forces
it to satisfy (b).

b. Suppose K is a submonoid and n ∼ n(cid:48). Then (m, m) and (n, n(cid:48)) are both in
K and (m, m)(n, n(cid:48)) = (mn, mn(cid:48)) so mn ∼ mn(cid:48). Similarly, nm ∼ n(cid:48)m. Conversely,
suppose ∼ is a congruence on M . Let (m, m(cid:48)) and (n, n(cid:48)) be elements of K. Then
m ∼ m(cid:48) and n ∼ n(cid:48), so by Exercise 1, (mn, m(cid:48)n(cid:48)) ∈ K. Finally, (1, 1) ∈ K because
the relation is reﬂexive. Thus K is a submonoid of M × M .

Solutions for Chapter 4

Solutions for section 4.1

449

Section 4.1

1.

A

C(cid:45)

(cid:64)
(cid:64)
f

(cid:64)

(cid:64)(cid:82)

g

(cid:63)
B

2. Let s be the function (x, y) (cid:55)→ (y, x). Then the diagram is

R × R

(cid:45)id

R × R

s

(cid:63)
R × R

+

(cid:63)
R(cid:45)

+

1

3.

(cid:161)(cid:170)
BOOLEAN

(cid:161)

true
(cid:161)

(cid:161)

(cid:190)

¬

CHAR

(cid:64)

true
(cid:64)

(cid:64)

(cid:64)(cid:82)
BOOLEAN

(cid:45)

(cid:161)

(cid:64)

(cid:161)

false

(cid:64)

(cid:64)

(cid:161)

(cid:63)
BOOLEAN

ord

(cid:64)
id

(cid:64)

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

¬
NAT(cid:45)
(cid:161)
chr

(cid:161)

CHAR
4. Let C and D be categories with sets of objects C0 and D0, sets of arrows C1
and D1, and sets of composable pairs of arrows C2 and D2, respectively. A functor
F : C −→ D consists of functions F0 : C0 −→ D0, F1 : C1 −→ D1 along with the

450

Solutions for section 4.2

uniquely determined function F2 : C2 −→ D2 such that

(cid:161)

(cid:161)

proj1
(cid:161)
(cid:161)(cid:170)

C1

F1

(cid:161)

proj1
(cid:161)

(cid:161)

(cid:161)(cid:170)

(cid:63)
D1

(cid:64)

C2

F2

(cid:63)
D2

(cid:64)

(cid:64)

proj2
(cid:64)
(cid:64)(cid:82)

C1

proj2
(cid:64)

(cid:64)

(cid:64)(cid:82)

F1

(cid:63)
D1

commutes. In addition, the following diagrams must commute:

C1

(cid:45)dom

C0

(cid:190) cod

C1

C2

comp

(cid:45)

C1

F1

(cid:63)
D1

F0
(cid:63)
D0

(cid:190)

cod

(cid:45)

dom

F1
(cid:63)
D1

F2

(cid:63)
D2

F1
(cid:63)
D1

(cid:45)

comp

Section 4.2

1. It is the model M deﬁned by M (n) = {n, a}, M (a) = {source, target},

M (source)(source) = M (source)(target) = a

and

M (target)(source) = M (target)(target) = n

2. Deﬁne an isomorphism φ : u-Struc −→ Mod(U , Set) as follows (these are the
constructions in 4.2.15). If (S, f ) is a u-structure, φ(S, f ) is the model of U that
takes u0 to S and e to f . If h : (S, f ) −→ (T, g) is a homomorphism, then φ(h) is the
natural transformation whose only component (at u0) is h. The inverse of φ takes
a model M to M (u0) and a natural transformation γ to its only component.

An isomorphism ψ : u-Struc −→ N-Act can be deﬁned this way: If (S, f ) is
a u-structure, the action α : N × S −→ S is deﬁned by α(k, x) = f k(x), where f k
denotes f ◦ f ◦ . . . ◦ f (k occurrences of f ) as in 2.3.5. This is indeed an action,
since α(0, x) = f 0(x) = x and

α(k + k(cid:48), x) = f k+k(cid:48)

(x) = f k(f k(cid:48)

(x)) = α(k, α(k(cid:48), x))

The inverse to ψ takes an action α : N × S −→ S to the u-set (S, f ), where f (x) =
α(1, x).

Solutions for section 4.2

451

3. The arrow category has as objects arrows f : C −→ D and an arrow from f : C
−→ D to f (cid:48) : C (cid:48) −→ D(cid:48) is a pair of arrows (g, h) where g : C −→ C (cid:48) and h : D −→ D(cid:48)
are such that

C

g

(cid:63)
C (cid:48)

D(cid:45)f

h
(cid:63)
D(cid:48)(cid:45)

f (cid:48)

commutes. The slice C /B is the subcategory that consists of those objects f : C
−→ D for which D = B and those arrows (g, h) for which h = idB. Since it does not
include all arrows between objects of the arrow category, it is not full (nor, since it
does not include all the objects, is it wide).

4. An object of Mod(G , C ) is given by a graph homomorphism G −→ C . Since G
has two nodes such a homomorphism is given by a pair of objects of C . Since there
are no arrows in G , such a pair of arrows is exactly a graph homomorphism so the
objects of Mod(G , C ) are the pairs. An arrow from one pair to another is a pair
of arrows as in C × C , which are generally subject to commutativity conditions
corresponding to arrows of G . Since G has no arrows, there are no conditions in
this case.

5. If (h, k) : f −→ g is an isomorphism with inverse (h(cid:48), k(cid:48)), then we have (h ◦
h(cid:48), k ◦ k(cid:48)) = (h, k) ◦ (h(cid:48), k(cid:48)) = idg = (idC, idD) so that h ◦ h(cid:48) = idC and k ◦ k(cid:48) =
idD. Similarly, h(cid:48) ◦ h = idA and k(cid:48) ◦ k =−1 idB. Conversely, suppose h and k are
invertible. Then we must show that (h−1, k−1) is an arrow from g −→ f . We have

f ◦ h−1 = k−1 ◦ k ◦ f ◦ h−1 = k−1 ◦ g ◦ h ◦ h−1 = k−1 ◦ g

It is evident that (h−1, k−1) = (h, k)−1.

6. Let f : D −→ D(cid:48) be an arrow of D . There are objects C and C (cid:48) of C and
isomorphisms h : D −→ F (C) and k : D(cid:48) −→ F (C (cid:48)). The arrow k ◦ f ◦ h−1 : F (C)
−→ F (C (cid:48)) is F (g) for a unique g : C −→ C (cid:48) because an equivalence is full and faithful.
Then k ◦ f = F (g) ◦ h, which means that (h, k) is an arrow from f to F (g). Since
h and k are isomorphisms, so is (h, k) (see previous exercise).
7. An object of C −→ is an arrow A(u) : A(0) −→ A(1) of C and an arrow (f (0), f (1)) :
A(u) −→ B(u) is a commutative square

A(0)

A(1)(cid:45)A(u)

f (0)

f (1)

(cid:63)
B(0)

(cid:63)
B(1)(cid:45)

B(u)

452

Solutions for section 4.2

A functor A : G −→ C −→ is thus required to produce, for each node a of G an arrow
A(a, u) : A(a, 0) −→ A(a, 1) and to each arrow s : a −→ b a commutative diagram

A(a, 0)

(cid:45)A(a, u)

A(a, 1)

A(s, 0)

A(s, 1)

(cid:63)
A(b, 0)

(cid:63)
A(b, 1)

(cid:45)

A(b, u)
If we let E(a) = A(a, 0), E(s) = A(s, 0), one sees immediately that E : G −→ C is
a model. Similarly, if we let F (a) = A(a, 1) and F (s) = A(s, 1) it is also a model.
Finally, deﬁne α : E −→ F by α(a) = A(a, u). The commutativity above implies that
α is a natural transformation. Conversely, we can start with a natural transforma-
tion α : E −→ F between two models and use the equations above to deﬁne A. The
details are trivial.

8. We have to show that the naturality condition engendered by an arrow f : a
−→ b in G is satisﬁed by β, given that it is satisﬁed by α. We have

D(f ) ◦ βa = βb ◦ αb ◦ D(f ) ◦ βa = βb ◦ E(f ) ◦ αa ◦ βa = βb ◦ E(f )

(Compare this argument with that of Exercise 5 above.)

Section 4.3

1. Recall that if G is graph, ηG is the identity on objects and is deﬁned on arrows
by ηG [u] = (u), where we use square brackets to denote application to distinguish
it from the parentheses used for lists. If f : G −→ H is a graph homomorphism, we
have to show that

G

f

(cid:63)

H

(cid:45)ηG

U (F (G ))

U (F (f ))

(cid:63)

U (F (H ))

(cid:45)

ηH

commutes. Applied to objects, we get ηH ◦ f [a] = f [a], while

U (F (f )) ◦ ηG [a] = U (F (f ))[a] = f [a]

If u : a −→ b is an arrow, ηH ◦ f [u] = (f [u]), while

U (F (f )) ◦ ηG [u] = U (F (f ))[(u)] = (f [u])

2. We must show that if f : G −→ H is a graph homomorphism,

G

f

(cid:63)

H

(cid:45)βG

W (G )

W (f )

(cid:63)
W (H )

(cid:45)

βH

Solutions for section 4.3

453

commutes. But for a node a of G , W (f )(βG (a)) is calculated as the component
of H containing f (a), which is exactly what βH (f (a)) is. In other words, the
naturality is the very deﬁnition of W (f ).
3. We must show that for each arrow f : C −→ C (cid:48) of C ,

G(C)

(cid:45)iC

F (C)

G(f )

F (f )

(cid:63)
G(C (cid:48))

(cid:63)
F (C (cid:48))

(cid:45)

iC(cid:48)

commutes. We have, for x ∈ G(C),

F (f )((iC)(x)) = F (f )(x) = G(f )(x) = iC(cid:48)(G(f )(x))

4. We must show that for any graph homomorphism f : G −→ H , the square

A(G )

source G

(cid:45)

N (G )

A(f )

N (f )

(cid:63)
A(H )

(cid:63)
N (H )

(cid:45)

source H
commutes. We have for u : a −→ b in G , N (f )(source G (u)) = N (f )(a) = f (a), while
source H (A(f )(u)) = source(f (u)) = f (a). The argument for target is similar.
5. A functor F : C −→ Set is determined uniquely by giving, for each C ∈ C0, a set
F (C). The disjoint union of these sets can be modeled as W (F ) =
{(x, C) | x ∈
F (C)}. The function w(F ) : W (F ) −→ C0 deﬁned by w(F )(x, C) = C makes w(F )
an object of Set/C0. Given a natural transformation α : F −→ G, deﬁne W (α) :
W (F ) −→ W (G) by W (α)(x, C) = (αC(x), C). This makes W : Func(C , Set) −→
Set/C0 a functor.

(cid:83)

Conversely, given an object f : S −→ C0 of Set/C0, deﬁne a functor V (f ) : C
−→ Set by V (f )(C) = {x ∈ S | f (x) = C} for an object C of C . If u : f −→ g : S(cid:48)
−→ C0 is an arrow of Set/C0, deﬁne a natural transformation V (u) : V (f ) −→ V (g)
by (V (u)C)(x) = u(x) for x ∈ S(cid:48). Then V : Set/C0 −→ Func(C , Set) is a functor.
We have that V (W (F ))(C) = {(x, C) | x ∈ F (C)}. Let βC(x, C) = x for x ∈
F (C). Then β is a natural isomorphism from V ◦ W to the identity functor on
Func(C , Set). In the other direction, for f : S −→ C0,

(cid:91)

W (V (f )) =

{(x, C) | x ∈ V (f )(C)} = {(x, f (x)) | x ∈ S}

which is isomorphic to S. The diagram

S

(cid:64)

(cid:161)

(cid:161)

(cid:64)

f
(cid:64)
(cid:64)(cid:82)
C0(cid:45)

w(V (f ))

∼=
(cid:161)
(cid:161)(cid:170)
W (V (f ))

commutes and the naturality of the isomorphism is straightforward to verify.

454

Solutions for section 4.3

6. a. We must show that if f : S −→ T is a function, then

PS(cid:45){}S

S

f

(cid:63)
T

f∗

(cid:63)
PT(cid:45)

{}T

commutes. But each path applied to an x ∈ S produces {f (x)}.

b. The diagram that would have to commute is

PS(cid:45){}S

S

f

(cid:63)
T

f!

(cid:63)
PT(cid:45)

{}T

for an f : S −→ T . The reader may want to verify that it does if and only if f
is injective. When, for example, f : 2 −→ 1 is the unique function, going around
counter-clockwise gives, at 0, the element {0}. Going the other way, we get f!({0})
which is the set of x ∈ 1 whose every inverse image is included in {0}. Since no
element of 1 has this property, f!{0} = ∅.

c. It makes no sense to ask for a natural transformation between a contravariant

functor and a covariant functor.

7. A natural transformation from F −→ G is a function f from S = F (M ) to T =
G(M ) and it must satisfy the naturality condition that for any a ∈ M ,

α(a, −)

S(cid:45)

S

f

(cid:63)
T

f

(cid:63)

T(cid:45)

β(a, −)

commutes. This is the deﬁnition of an equivariant function.

8. This refers to the answer to Exercise 7 of Section 4.2. In addition to that, in
describing a model A : D −→ C −→ we must add, whenever we have arrows s : a
−→ b and t : b −→ c of D , the equations A(t, 0) ◦ A(s, 0) = A(t ◦ s, 0) and A(t, 1) ◦
A(s, 1) = A(t ◦ s, 1). Similar equations have to be added for E and F and will
satisﬁed if and only if they are for A.

9. If F, G : E −→ G is such that α(F ) = α(G), then the sole vertex of α(F ) is the
same as that of α(G). But that is all there is to a homomorphism on E . Thus α is
injective. Similarly, every node of G does give graph homomorphism on E so α is
surjective.

Solutions for section 4.4

455

10. a. If f : G −→ H is a graph homomorphism, we deﬁne

Pk(f )((un, un−1, . . . , u1)) = (f (un), f (un−1), . . . , f (u1))

This makes sense since f preserves source and target. The functoriality is clear.

b. A path of length 0 goes from a node n to itself (if you don’t go anywhere,
you stay in the same place!). The natural isomorphism takes a path of length 0 to
the node n that it determines. The naturality condition is trivial.

c. Since a path of length 1 is an arrow, the object functions of P1 and A are
the same. The arrow functions are the same by deﬁnition. Thus the components of
the required natural isomorphism are identity functions.

Section 4.4

1. By Deﬁnition 4.4.2, the component of (G1α)E at an object A of A is the arrow
(G1α)E(A). This is G1(αE(A)) by Deﬁnition 4.4.3. By Deﬁnition 4.4.3, the com-
ponent of G1(αE) at A is G1((αE)A). This is G1(αE(A)) by Deﬁnition 4.4.2.

2. The horizontal composites β ∗ idF and idH ∗α are deﬁned to be the two equal
composites in each of these special cases of Diagram (4.30):

(H ◦ F )A

H(idF )A

(cid:45)

(H ◦ F )A

(βF )A

(βF )A

(cid:63)
(K ◦ F )A

(cid:45)

K(idF )A

(cid:63)
(K ◦ F )A

(H ◦ F )A

(Hα)A

(cid:45)

(H ◦ G)A

(idH )F A

(idH )GA

(cid:63)
(H ◦ F )A

(cid:63)

(H ◦ G)A

(cid:45)

(Hα)A

H(idF )A = H(idF A) = id(H ◦F )A

Since

(the ﬁrst equality by the deﬁnition of identity natural transformation in 4.2.13), we
have that

(β ∗ idF )A = (βF )A ◦ idH ◦F A = (βF )A

as required. Similarly (idH )GA = id(H ◦G)A, so that

(idH ∗α)A = (idH )GA ◦ (Hα)A = (Hα)A

3. a. The ﬁrst equation in Godement’s ﬁfth rule follows from this calculation, using
the Interchange Law and Exercise 2.

(γF2) ◦ (G1α) = (γ ∗ idF2 ) ◦ (idG1 ∗α)

= (γ ◦ idG1) ∗ (idF2

◦ α) = γ ∗ α

456

Solutions for section 4.4

A similar argument shows that γα = (G2α) ◦ (γF1)

b. This is shown by the following calculation, using (in order) Exercise 2, the In-
terchange Law, the deﬁnition of the (vertical) composite of natural transformations
and Exercise 2 again:

(G1βE) ◦ (G1αE) = (idG1 ∗βE) ◦ (idG1 ∗αE)
= (idG1
◦ idG1 ) ∗ (βE ◦ αE)
= idG1 ∗(β ◦ α)E = G1(β ◦ α)E

Section 4.5

1. Let F : C −→ Set be representable. Then if 1 is a terminal object in C , then
F (1) is isomorphic to Hom(C, 1), so has exactly one element, so is a terminal object
in Set.

On the other hand, HomSet(∅, ∅) contains exactly one element (the identity
function on the empty set), so is not the initial object of Set, which is the empty
set.

2. Let H = HomSet(1, −) and I the identity functor. Let α : H −→ I assign to each
function from 1 to I the element which is the image of that function. This is clearly
bijective. If f : S −→ T is a function, we have to show that the diagram

H(S)

I(S)(cid:45)αS

H(f )

I(f )

(cid:63)
H(T )

(cid:63)
I(T )(cid:45)

αT

commutes. If we take a function g : 1 −→ S whose value is x ∈ S, then

I(f )(αS(g)) = I(f )(x) = f (x) = αT (f ◦ g) = αT (H(f )(g))

3. A graph homomorphism 2 −→ G takes e to an arrow u of G and takes 0 to the
source of u and 1 to the target of u. In other words, it is completely determined
by u. Thus A(G ) ∼= Hom(2, G ). It remains only to show that the isomorphism is
natural in G . If f : G −→ H , we must show that

A(G )

(cid:45)∼=

Hom(2, G )

A(f )

Hom(2, f )

(cid:63)
A(H )

(cid:63)
Hom(2, H )

(cid:45)

∼=

commutes. Then for an arrow u of G , let h : 1 −→ G be deﬁned by h(e) = u. Then
the upper route in the diagram takes u to h and then to f ◦ h, whereas the lower
route takes u to f (u) and then to the homomorphism h(cid:48) deﬁned by h(cid:48)(e) = f (u).
Since (f ◦ h)(e) = f (h(e)) = f (u), the two are the same.

Solutions for section 4.5

457

4. Global elements are arrows from the terminal object. In the case of categories,
the terminal object is the category 1 with one object and one arrow, the identity of
that object. A functor from that object is determined by where it sends that object,
which can be to any arbitrary object. The identity is sent to the identity of that
chosen object. Thus HomCat(1, C ) is isomorphic to the set of objects of C . The set
of objects is a functor O : Cat −→ Set: if F : C −→ D is a functor then O(F ) is F0,
the object part of the functor. To verify naturality amounts to showing that if G : 1
−→ C is a functor, then Hom(1, F )(G(∗)) = F (G(∗)) which is immediate from the
deﬁnition. (This says that the global elements of a category are its objects. Note
that the global elements of a graph are its loops.)

5. Yes and yes. The representing object is the category 2 which is the graph 2
with the addition of two identity arrows. The argument is virtually identical to the
argument for graphs.

6. Set F ∗(C) = {(x, C) | x ∈ F (C)} and for f : C −→ D, set F ∗(f )(x, C) = (F (f )(x), D).
The function βC = x (cid:55)→ (x, C) is clearly an isomorphism. To be natural requires
that F ∗(f )(βC(x)) be the same as βD(F (f )(x)), which is immediate from the def-
inition.

7. D is represented by {1, 2} (or any other two-element set) and a universal object
is (1, 2) (or any other pair with distinct coordinates.) The natural isomorphism from
Hom({1, 2}, A) to A × A takes a function f : {1, 2} −→ A to the pair (f (1), f (2)).
The inverse takes a pair (a1, a2) to the function f for which f (i) = ai.
8. Let D = C op. Then the ordinary Yoneda embedding

D op −→ Func(D , Set)

is full and faithful. But C op = D means D op = C so this is just 4.5.5.

9. For each c ∈ F (C), deﬁne a natural transformation β(C, F )(c) : Hom(C, −) −→ F
as follows: for each k : C −→ A, let β(C, F )(c)(k) = F (f )(c). (This is the natu-
ral transformation deﬁned by 4.5.6.) This is the value at c of a function we call
β(C, F ) : F (C) −→ NT(Hom(C, −), F ) where NT(G, F ) stands for the set of natural
transformations between functors G and F . It is easy to see that NT(G, F ) is con-
travariant in G and covariant in F . It is, in fact, the hom functor in the category
Func(C, Set). Then the formulation of naturality is that if f : C −→ C (cid:48) is an arrow
and α : F −→ F (cid:48) is a natural transformation, the square

F (C)

β(C, F )

(cid:45)

NT(Hom(C, −), F )

αf

(cid:63)
F (cid:48)(C (cid:48))

NT(Hom(f, −), α)

(cid:45)

β(C (cid:48), F (cid:48))

(cid:63)
NT(Hom(C (cid:48), −), F (cid:48))

commutes. Here αf is deﬁned to be F (cid:48)f ◦ αC = αC (cid:48) ◦ F f , equal by naturality. Note
the double contravariance. From f : C −→ C (cid:48), we get

Hom(f, −) : Hom(C (cid:48), −) −→ Hom(C, −)

458

Solutions for section 4.5

and then

NT(Hom(C, −), F ) −→ NT(Hom(C (cid:48), −), F )

Now to prove this, we must apply it to a c ∈ F (C). Going around clockwise gives
us the natural transformation from Hom(C (cid:48), −) −→ F (cid:48) whose value at an object A
takes an arrow g : C (cid:48) −→ A to αA(F (g ◦ f )(c)). Going the other way we get the
natural transformation whose value at an object A is F (cid:48)g(αC (cid:48)(F f (c))). From the
functoriality of F and naturality of α, we have

αA(F (g ◦ f )(c)) = αA(F g(F f (c))) = F (cid:48)g(αC (cid:48)(F f (c)))

10. If c ∈ F (C) is a universal element of F , then there is a unique f : C −→ C (cid:48) such
that F f (c) = c(cid:48). Symmetrically, there is a unique g : C (cid:48) −→ C such that F g(c(cid:48)) = c.
Then F g(F f (c)) = F g(c(cid:48)) = c. But the universality of c says that there is a unique
arrow h : C −→ C such that F h(c) = c. Clearly, h = idC is one such; it follows that
g ◦ f = idC. Symmetrically, f ◦ g = idC(cid:48).

Section 4.6

1. Let S be the sketch whose graph has one node ∗ and no arrows, and (necessarily)
no diagrams. If M is a model of S , M determines and is determined by M (∗), which
is a set. If N is a model and α : M −→ N a natural transformation, then α has only
one component, namely αM , and the naturality condition of Diagram (4.20) is
vacuous since the sketch has no arrows. The isomorphism takes M to M (∗) and α
to αM .

2. The sketch has one node, call it s, and two arrows u, v : s −→ s. There is one
diagram D : I −→ S based on the shape

i

b

j(cid:45)a

c

(cid:63)

l(cid:45)

(cid:63)
k

d

deﬁned by D(i) = D(j) = D(k) = D(l) = s, D(a) = D(d) = u and D(b) = D(c) =
v.

3. Since the sketch underlying a category has the same objects as the category
and since the theory of a linear sketch also has the same objects as the sketch,
the objects are same. For each arrow f : A −→ B, there is an arrow in the sketch.
Whenever (f1, f2, . . . , fn) is a path in the graph underlying C there is a diagram
(f1, f2, . . . , fn) = (f1 ◦ f2 ◦ · · · ◦ fn) so that in the theory category every path is
equal to a single arrow and the obvious functor is full. It is also faithful since there
is no relation among paths in the theory that does not come from a commutative
diagram in C .

Solutions for section 4.8

459

4. In general a homomorphism must commute in that way with every arrow in the
sketch. However, an arrow that commutes in this way with an invertible arrow also
commutes with the inverse:

f ◦ M (v) = N (v) ◦ N (u) ◦ f ◦ M (v)

= N (v) ◦ f ◦ M (u) ◦ M (v) = N (v) ◦ f

5. The theory has nodes 0 and 1. The arrows are given by

(i) Hom(0, 0) = {id0, u ◦ v}.

(ii) Hom(1, 1) = {id1, v ◦ u}.

(iii) Hom(1, 0) = {v, v ◦ u ◦ v}.

(iv) Hom(0, 1) = {u}.

The nontrivial composites are given by u ◦ v ◦ u = u, v ◦ u ◦ v ◦ u = v ◦ u, and
u ◦ v ◦ u ◦ v = u ◦ v.

Section 4.7

1. I(0) = {[x], [vux], [vy], [vuvy]} and I(1) = {[y], [uvy], [ux]}. For any element [z]
of I(0), I(u)([z]) = [uz] and for any element [w] of I(1), I(v)([w]) = [vw], all subject
to the equation uvu = u.

2. If two terms are forced to be equal by the equivalence relation, then they are
certainly equal in every model since the relations are valid in every model. On the
other hand, the theory is a model and if the two terms are not forced to be equal
by the equivalence relation, they are not equal in the theory.

3. Deﬁne the model T : S −→ Set this way: for any node a of the sketch, T (a) =
{∗} (any one element set will do). For any arrow f : a −→ b, T (f ) is the only possible
function. If x is a constant of type a, then set T (x) = ∗ (the only possibility). If S
has diagrams, T automatically takes them to commutative diagrams. If M is any
model of S , there is just one natural transformation from M to T whose value at
a node a is the only possible map M (a) −→ T (a) = {∗}. The requisite naturality
diagram commutes because there is only one possible map to {∗} from any set.

Section 4.8

1. Suppose the composites β ∗ α, δ ∗ γ, γ ◦ α and δ ◦ β are all deﬁned. We must
show that codv(β ∗ α) = domv(δ ∗ γ).

idv codv(β ∗ α) = idv codv β ∗ idv codv α
= idv domv δ ∗ idv domv γ
= idv domv(δ ∗ γ)

TC–5

TC–5

where the second equality is because δ ◦ β and γ ◦ α are both deﬁned.

460

Solutions for section 4.8

2. We must show that for all posets A, B and C (with the ordering written ≤ in
all of them), comp : Hom(B, C) × Hom(A, B) −→ Hom(A, C) is monotone. Suppose
f ≤ g : A −→ B and h ≤ k : B −→ C. We must show that h ◦ f ≤ k ◦ g. For any
x ∈ A, h(f (x)) ≤ h(g(x) because f ≤ g and h is monotone, and h(g(x)) ≤ k(g(x))
because h ≤ k. The result follows from transitivity.

3. Let α and α(cid:48) be relations from A to B, γ and γ(cid:48) relations from B to C, and
α ⊆ α(cid:48) and γ ⊆ γ(cid:48). We must show that γ ◦ α ⊆ γ(cid:48) ◦ α(cid:48). Suppose (x, z) ∈ γ ◦ α.
Then there is y ∈ B such that (x, y) ∈ α and (y, z) ∈ γ. But then (x, y) ∈ α(cid:48) and
(y, z) ∈ γ(cid:48), so that (x, z) ∈ γ(cid:48) ◦ α(cid:48) as required.

4. Let f, f (cid:48) : A −→ B be partial functions with f deﬁned on A0 and f (cid:48) deﬁned on
0, and g, g(cid:48) : B −→ C partial functions with g deﬁned on B0 and g(cid:48) deﬁned on
A(cid:48)
B(cid:48)
0. We must show that if f ≤ f (cid:48) and g ≤ g(cid:48), then domain of deﬁnition of g ◦ f
is included in the domain of deﬁnition of g(cid:48) ◦ f (cid:48) and for x such that g(f (x)) is
deﬁned, g(cid:48)(f (cid:48)(x)) = g(f (x)). So suppose g(f (x)) is deﬁned for some x ∈ A. Then
by deﬁnition of composition in 2.1.13, x ∈ A0 and f (x) ∈ B0. By the assumption
0 and f (cid:48)(x) = f (x). Hence f (cid:48)(x) ∈ B0 and g(f (cid:48)(x)) is deﬁned
that f ≤ f (cid:48), x ∈ A(cid:48)
and equal to g(f (x)). Now the assumption that g ≤ g(cid:48) means that f (cid:48)(x) ∈ B(cid:48)
0 and
g(f (cid:48)(x)) = g(cid:48)(f (cid:48)(x)). Hence g(f (x)) = g(cid:48)(f (cid:48)(x)) as required.

Solutions for Chapter 5

Section 5.1

1. Let C , D and E be categories. The category C × D has functors P1 : C × D
−→ C and P2 : C × D −→ D deﬁned by P1(C, D) = C, P2(C, D) = D, P1(f, g) = f
and P2(f, g) = g for C and D objects and f and g arrows of C and D respectively.
That these are functors follows immediately from the fact that source, target and
composition in the product category are deﬁned coordinatewise (see 2.6.6). Now
let F : E −→ C and G : E −→ D be functors. Deﬁne (cid:104)F, G(cid:105) : E −→ C × D by
(cid:104)F, G(cid:105)(E) = (F (E), G(E)) and (cid:104)F, G(cid:105)(h) = (F (h), G(h)) for E an object and h an
arrow of E . The proof that this is a functor is immediate. Then P1 ◦ (cid:104)F, G(cid:105)(E) =
P1(F (E), G(E)) = F (E) and similarly for arrows. And similarly, P2 ◦ (cid:104)F, G(cid:105) = G.
If H : E −→ C × D is any functor with P1 ◦ H = F and P2 ◦ H = G, let H(E) =
(H1(E), H2(E)). Then F (E) = P1 ◦ H(E) = H1(E) and similarly for arrows. Thus
F = H1 and similarly G = H2, which proves uniqueness.

2. Let M and N be monoids. The product is the product of the underlying sets
with multiplication (m1, n1)(m2, n2) = (m1m2, n1n2). The identity element is (1, 1).

3. If P and Q are posets, their product is the product of the underlying sets with
(p1, q1) ≤ (p2, q2) if and only if p1 ≤ p2 and q1 ≤ q2.

4. This is essentially the same as for categories.

5. A cone over A and 1 has to have this form, where f : B −→ A is any arrow.

Solutions for section 5.2

461

B

(cid:161)

(cid:64)

(cid:64)

(cid:104)(cid:105)
(cid:64)

(cid:64)(cid:82)
1(cid:45)

(cid:104)(cid:105)

(cid:63)
A

(cid:161)

f
(cid:161)

idA

(cid:161)(cid:170)
(cid:190)

A

Clearly the only possible arrow in the middle is f .

6. In the category of sets the product of any set A with the empty set is the
empty set. If A is nonempty, the projection onto A is not surjective, hence not an
epimorphism.

Section 5.2

1. The isomorphism is given by

f (x) =






(2, 1)
(1, 1)
(3, 1)
(2, 2)
(1, 2)
(3, 2)

if x = 1
if x = 2
if x = 3
if x = 4
if x = 5
if x = 6

2. The isomorphism of the preceding exercise can be composed with any of the
6! = 720 permutations of 6 to give another one.

3. By 5.2.13, the left vertical arrow in (5.12) takes the pair of arrows (q1, q2), where
q1 : W −→ A and q2 : W −→ B, to (q1 ◦ f, q2 ◦ f ), and the right vertical arrow takes
q : W −→ A × B to q ◦ f : V −→ A × B. Therefore, by Deﬁnition 5.2.7, if you start
at lower left with (q1, q2) and go north and then east, you get the unique arrow q(cid:48)
which makes

V

(cid:161)

(cid:64)

(cid:161)

q(cid:48)

(cid:161)

q1 ◦ f
(cid:161)

(cid:161)(cid:170)
(cid:190)

A

proj1

(cid:63)
A × B

(cid:64)

(cid:64)

q2 ◦ f
(cid:64)

(cid:64)(cid:82)
B(cid:45)

proj2

(∗)

commute. If you go east and north, you get q ◦ f , where q is the unique arrow which
makes

W

(cid:161)

(cid:64)

q

(cid:161)

(cid:64)

(cid:63)
A × B

q2

(cid:64)

(cid:64)

proj2

(cid:64)(cid:82)
B(cid:45)

(cid:161)

q1

(cid:161)

proj1

(cid:161)(cid:170)
(cid:190)

A

462

Solutions for section 5.2

commute. Because proji ◦ (q ◦ f ) = (proji ◦ q) ◦ f = qi ◦ f for i = 1, 2, it follows
that q ◦ f = q(cid:48). This is a consequence of the fact that q(cid:48) is the unique arrow making
(∗) commute. Hence (5.12) commutes.

4. Let f : E −→ A and g : E −→ B. Then i−1 ◦ (cid:104)f, g(cid:105) : C −→ V is an arrow such that

proj1 ◦ i ◦ i−1 ◦ (cid:104)f, g(cid:105) = proj1 ◦ idC ◦ (cid:104)f, g(cid:105) = proj1 ◦ (cid:104)f, g(cid:105) = f
and similarly proj2 ◦ i ◦ i−1 ◦ (cid:104)f, g(cid:105) = g. Moreover if h : E −→ V is such that proj1 ◦
i ◦ h = f and proj2 ◦ i ◦ h = g, then we have p1 ◦ i ◦ h = p1 ◦ i ◦ i−1 ◦ (cid:104)f, g(cid:105) and
p2 ◦ i ◦ h = p2 ◦ i ◦ i−1 ◦ (cid:104)f, g(cid:105). But since arrows to C are uniquely determined by
their projections to A and B, we conclude that i ◦ h = i ◦ i−1 ◦ (cid:104)f, g(cid:105) from which
the isomorphism i can be cancelled to give h = i−1 ◦ (cid:104)f, g(cid:105).

5. Chase the diagram

X

(cid:161)

(cid:64)

(cid:161)

u
(cid:161)

(cid:161)(cid:170)
(cid:190)

p1

A

f

(cid:63)
C

(cid:190)

p1

(cid:104)u, v(cid:105)

(cid:63)
A×B

f ×g

(cid:63)
C × D

(cid:64)

v
(cid:64)

(cid:64)(cid:82)
B(cid:45)

p2

g

(cid:63)

D(cid:45)

p2

to show that

p1 ◦ (f × g) ◦ (cid:104)u, v(cid:105) = f ◦ p1 ◦ (cid:104)u, v(cid:105) = f ◦ u

and similarly p2 ◦ (f ×g) ◦ (cid:104)u, v(cid:105) = g ◦ v, so that (f ×g) ◦ (cid:104)u, v(cid:105) satisﬁes the condition
that determines the map (cid:104)f ◦ u, g ◦ v(cid:105) uniquely.

Section 5.3

1. a. Deﬁne q1 = proj1 : A × (B × C) −→ A, q2 = proj1 ◦ proj2 : A × (B × C) −→ B
and q3 = proj2 ◦ proj2 : A × (B × C) −→ C. The meaning of the last, for example,
is the second projection to B × C, followed by the second projection from the
latter to C. Now suppose D is an object and f1 : D −→ A, f2 : D −→ B and f3 : D
−→ C are given. Then there is a unique arrow (cid:104)f2, f3(cid:105) : D −→ B × C such that
proj1 ◦ (cid:104)f2, f3(cid:105) = f2 and proj2 ◦ (cid:104)f2, f3(cid:105) = f3. It follows that there is a unique
arrow (cid:104)f1, (cid:104)f2, f3(cid:105)(cid:105) : D −→ A × (B × C) such that proj1 ◦ (cid:104)f1, (cid:104)f2, f3(cid:105)(cid:105) = f1 and
proj2 ◦ (cid:104)f1, (cid:104)f2, f3(cid:105)(cid:105) = (cid:104)f2, f3(cid:105) from which the required identities follow immediately.
If g : D −→ A × (B × C) is another arrow with qi ◦ g = fi for i = 1, 2, 3, then
proj1 ◦ proj2 ◦ g = f2 and proj2 ◦ proj2 ◦ g = f3, from which it follows from the
uniqueness of arrows into a product, that proj2 ◦ g = (cid:104)f2, f3(cid:105). Also, p1 ◦ g = f1 so
that g = (cid:104)f1, (cid:104)f2, f3(cid:105)(cid:105).

b. If p : B −→ A is a unary product diagram, then by deﬁnition there is for each

object X a bijection

f (cid:55)→ (cid:104)f (cid:105) : Hom(X, A) −→ Hom(X, B)

Solutions for section 5.3

463

for which p ◦ (cid:104)f (cid:105) = f . This bijection is a natural isomorphism from Hom(−, A)
to Hom(−, B): if u : Y −→ X, then naturality follows from the fact that p ◦ (cid:104)f (cid:105) ◦
u = f ◦ u, so that (cid:104)f (cid:105) ◦ u = (cid:104)f ◦ u(cid:105). It follows from Corollary 4.5.4 that p is an
isomorphism.

c. The preceding part shows that every category has unary products, so such a
category has n-ary products for n = 0, 1 and 2. The ﬁrst part shows the same for
n = 3 and also gives for that case the essential step for an obvious induction on n.

2. Given q1 and q2 as in (ii), we form (cid:104)q1, q2(cid:105). From (iii), we see that p1 ◦ (cid:104)q1, q2(cid:105) = q1
and p2 ◦ (cid:104)q1, q2(cid:105) = q2. If h is another arrow satisfying the same identities, then (iv)
tells us that h = (cid:104)p1 ◦ h, p2 ◦ h(cid:105) = (cid:104)q1, q2(cid:105) so that we have the uniqueness required
by 5.1.3.

3. We saw in Exercises 1 and 4 of Section 5.1 that the product in each category
took as objects of the product category the product of the objects and as arrows
of the product the product of the arrows. Thus the product is constructed in the
same way in both categories.

4. Let C = D be the category of countably inﬁnite sets and all functions between
them. Let F : C −→ D be deﬁned by F (X) = {X} ∪ X for such a set X (the idea
is that F (X) is X with a new element adjoined; the choice of {X} to be the new
element is convenient but not the only possible one) and if f : X −→ Y , F (f ) = 1 + f
is the function whose restriction to X is f and which takes the added element {X}
of F (X) to the added element {Y } of Y . Then although F (X × Y ) ∼= F (X) × F (Y )
since any two countable sets are isomorphic, the cone

F (X × Y )
(cid:161)
(cid:64)

(cid:161)

F (proj1)
(cid:161)
(cid:161)(cid:170)

F (X)

(cid:64)

F (proj2)
(cid:64)
(cid:64)(cid:82)

F (Y )

is not a product cone. In fact, F (X × Y ) contains no point u with the property that
F (proj1)(u) = {X} but F (proj2)(u) (cid:54)= {Y } or vice versa.
5. a. Since a unary product diagram is an isomorphism and every functor pre-
serves isomorphisms, every functor preserves unary products. Now for n ≥ 3, n-ary
products are deﬁned by induction. Assuming that a functor F preserves n − 1-ary
products, then the product

A1 × A2 × · · · × An = A1 × (A2 × · · · × An)

Then

F (A1 × · · · × An)

F (proj1)
(cid:161)
(cid:161)(cid:170)
F (A1)

(cid:161)

(cid:161)

(cid:64)

(cid:64)

F (proj2)
(cid:64)
(cid:64)(cid:82)

F (A2 × · · · × An)

464

Solutions for section 5.3

is a product cone. By the inductive assumption so is

F (A2 × · · · × An)

(cid:161)

(cid:64)

F (proj1)
(cid:161)

(cid:161)(cid:170)
F (A2)

(cid:161)

(cid:161)

F (proji−1)

(cid:64)

(cid:64)

(cid:63)
· · · F (Ai)

· · ·

F (projn−1)
(cid:64)

(cid:64)(cid:82)
F (An)

from which the conclusion follows.

b. Let C = 1, the category with one object called 0 and its identity arrow. Let
D = 2, the category with two objects, called 0 and 1, their identities and one arrow
0 −→ 1. Then 0 is the terminal object of C and 1 is the terminal object of D . Both
categories have ﬁnite products, with 0n = 0 in both and 1n = 1 and 0 × 1 = 0 in D .
The products are canonical since there is only one possible choice. Then the functor
F : C −→ D given by F (0) = 0 preserves n-ary products for n ≥ 1, but not nullary
products.

6. A terminal object in a category is an object that every other object has an arrow
to (unique, of course). In a poset, that is an element that every element is less than
or equal to, that is a top element. There is no largest integer so N has no terminal
element. We saw in 5.1.8 that products in posets are just meets. Since the meet of
two nonnegative integers is the smaller of the two, N has binary products.

7. Suppose

F (P )

(cid:161)

(cid:64)

(cid:64)

F (p1)
(cid:64)(cid:82)

F (B)

F (p2)
(cid:161)(cid:170)

(cid:161)

F (A)

is a product diagram and φ : F −→ G is a natural isomorphism. Suppose

X

(cid:161)

g(cid:64)
(cid:64)
(cid:64)(cid:82)

F (B)

f
(cid:161)(cid:170)

(cid:161)

F (A)

is given. Then

X

(cid:161)

(cid:64)

φA ◦ f
(cid:161)(cid:170)

(cid:161)

G(A)

(cid:64)

φB ◦ g
(cid:64)(cid:82)

G(B)

induces a unique map u : X −→ G(P ) for which G(p1) ◦ u = φA ◦ f and G(p2) ◦ u =
φB ◦ g. The required map from X to F (P ) is φ−1
◦ u =
P
φ−1
◦ φA ◦ f = f by deﬁnition of
A
u. Similarly F (p2) ◦ φ−1
◦ u = g as required. Uniqueness follows from the fact that
P
u is unique and φP is an isomorphism

◦ G(p1) ◦ u by naturality, but the right side is φ−1
A

◦ u. We have F (p1) ◦ φ−1
P

Solutions for section 5.5

465

Section 5.4

1. Using the version of the disjoint sum of 5.4.5, deﬁne (f + g)(s, 0) = (f (s), 0) and
(f + g)(t, 1) = (g(t), 1).

2. Let P be a poset and x, y ∈ P . The sum x + y is characterized by the fact that
there is an arrow x + y −→ z corresponding to every pair consisting of an arrow x
−→ z and an arrow y −→ z. In a poset, there is an arrow x −→ z and only one if and
only if x ≤ z and similarly for y. Thus x + y ≤ z if and only if x ≤ z and y ≤ z. But
this property characterizes the join x ∨ y.

3. Let P and Q be two posets and P + Q denote the disjoint sum of the sets P
and Q as described in 5.4.5. Deﬁne (x, i) ≤ (y, i), i = 0, 1 if and only if x ≤ y, while
(x, 0) (cid:54)≤ (y, 1) and (x, 1) (cid:54)≤ (y, 0) for all x, y ∈ P + Q. The proof that this is the
sum is essentially the same as the sum for the category of sets, augmented by the
observation that an arrow from P + Q −→ R preserves the partial order just deﬁned
if and only if its restrictions to P and Q do.

4. As noted in 5.4.7, we can take the canonical injections to be the same as in Set:
i1(x) = (x, 0) for x ∈ S and i2(x) = (x, 1) for x ∈ T . Then given f : S −→ X, g : T
−→ X, deﬁne (cid:104)f |g(cid:105) : S + T −→ X by (cid:104)f |g(cid:105)(s, 0) = f (s) if and only if f (s) is deﬁned
and (cid:104)f |g(cid:105)(t, 1) = g(t) if and only if g(t) is deﬁned. Then, because i1 is deﬁned for
all x ∈ S, (cid:104)f |g(cid:105)(i1(x)) = (cid:104)f |g(cid:105)(x, 0) = f (x) if and only if f (x) is deﬁned, so that
(cid:104)f |g(cid:105) ◦ i1 = f , and similarly for g. It is clear that (cid:104)f |g(cid:105) is the only arrow such that
(cid:104)f |g(cid:105) ◦ i1 = f and (cid:104)f |g(cid:105) ◦ i2 = g.

5. Use the example given in the answer to Exercise 6 of Section 5.1 in the dual
category.

Section 5.5

1. Given sets A and B, a function f0 : B −→ A and t : A −→ A, deﬁne a function
f : B × N −→ A by letting f (b, 0) = f0(b) and having deﬁned f (b, i) for i ≤ n, deﬁne
f (b, n + 1) = t(f (b, n)).

2. To be a model M of that sketch is to be an object A = M (n) together with arrows
f0 = M (zero) : 1 −→ A and t = M (succ) : A −→ A, so that (N, 0, s) is certainly a
model. If (A, f0, t) is another model, then there is a unique arrow f : N −→ A such
that

(cid:161)(cid:181)
0(cid:161)

1
f0(cid:64)

(cid:64)(cid:82)

N

f

(cid:63)
A

s

N(cid:45)

f

(cid:63)

A(cid:45)

t

commutes. But the commutation of the two parts of that diagram express the fact
that f is an arrow in the category of models of the sketch. Since f is unique, this
shows that there is exactly one such arrow from (N, 0, s) to any other model of the
sketch, whence that is the initial model.

466

Solutions for section 5.5

3. Deﬁne t : B ×N×A −→ B ×N×A by t(b, n, a) = h(b, n, f (b, n)). Deﬁne k0 : B −→
B ×N×A by k0(b) = (b, 0, g(b)). Then the induction property gives an arrow k : B ×
N −→ B × N × A such that k(b, 0) = k0(b) = (b, 0, g(b)) and k(b, s(n)) = t(k(b, n)).
If we let ki = proji ◦ k, i = 1, 2, 3, then k(b, n) = (k1(b, n), k2(b, n), k3(b, n)). Next
we claim that k1(b, n) = b and k2(b, n) = n. For consider the diagram (in which we
have abbreviated proj as p)

B × N
(cid:161)(cid:181)

(cid:161)

k

(cid:63)

B × N × A

idB ×s

(cid:45)

B × N

k

(cid:63)

B × N × A

(cid:45)

t

(cid:104)p1, p2(cid:105)

(cid:104)p1, p2(cid:105)

(cid:64)

(cid:64)(cid:82)
(cid:63)
B × N
B × N

(cid:45)

(cid:63)
B × N

B × s

(cid:161)

(cid:104)idB, 0(cid:105)
(cid:161)
(cid:45)k0

(cid:161)

B

(cid:64)

(cid:64)
(cid:104)idB, 0(cid:105)

(cid:64)

Compare this to the diagram

B × N
(cid:161)(cid:181)

(cid:161)

id

(cid:104)idB, 0(cid:105)
(cid:161)

B

(cid:64)
(cid:104)idB, 0(cid:105)

(cid:64)

(cid:64)(cid:82)
(cid:63)
B × N

idB × succ

(cid:45)

B × N

id

(cid:45)

(cid:63)
B × N

idB × succ

and the uniqueness of recursively deﬁned arrows implies that

Then f = k3 has the required properties.

(cid:104)p1, p2(cid:105) ◦ k = (cid:104)idB, idN(cid:105)

Section 5.6

1. There is, by CC–1 and CC–2, a proof of A ⇒ true and only one for each object
A of C so that true is the terminal object. If q1 : X −→ A and q2 : X −→ B are
arrows in C , then from CC–3, there is an arrow (cid:104)q1, q2(cid:105) : X −→ A ∧ B. According
to CC–4, p1 ◦ (cid:104)q1, q2(cid:105) = q1 and p2 ◦ (cid:104)q1, q2(cid:105) = q2 and by CC–5, the arrow (cid:104)q1, q2(cid:105) is
unique with this property, so that A ∧ B together with p1 and p2 is a product of A
and B in C . The proof follows from Proposition 5.3.10.

2. a. Either projection is a proof.

b. (cid:104)idA, idA(cid:105) is a proof.
c. (cid:104)proj2, proj1(cid:105) is a proof.
d. (cid:104)proj1 ◦ proj1, (cid:104)proj2 ◦ proj1, proj2(cid:105)(cid:105) is a proof.

Solutions for section 6.1

467

Section 5.7

1. The reason for both categories is the same: they fail Proposition 5.7.3 (ii). In
Rel the product of 0 and S is the disjoint union of the empty set and S, that is,
it is S. Similarly in Mon, the initial object is isomorphic to the terminal object
whose product with any monoid M is M .
2. We have, for any objects X, Y and Z, that X + Y + X ∼= (X + Y ) + Z by the
dual of the argument in 5.3.3. Then D × (A + B + C) ∼= D × ((A + B) + C) ∼=
D × (A + B) + D × C ∼= (D × A + D × B) + D × C ∼= D × A + D × B + D × C.

3. The arrow h is the composite

C × T

idC ×c

−−−−−−→ C × (1 + 1 + 1)

∼=
−−→ C × 1 + C × 1 + C × 1

p1 + p1 + p1

−−−−−−−−−−→ C + C + C

f + g + h

−−−−−−−−→ D + D + D

(cid:104)idD | idD | idD(cid:105)

−−−−−−−−−−−−−→ D

Solutions for Chapter 6

Section 6.1

1. Deﬁne eval : [C −→ D ] × C −→ D on objects as follows. Let F : C −→ D and
let C be an object of C . Then eval(F, C) = F (C). On arrows, suppose α : F −→ F (cid:48)
is a natural transformation and f : C −→ C (cid:48) is an arrow of C . Then set eval(α, f ) =
F (cid:48)f ◦ αC = αC (cid:48) ◦ F f : F (C) −→ F (cid:48)(C (cid:48)) (they are the same by naturality).

Since (α, f ) is an arrow from (F, C) to (F (cid:48), C (cid:48)), eval preserves source and target
because eval(F, C) = F (C) and eval(F (cid:48), C (cid:48)) = F (cid:48)(C (cid:48)). Preservation of identities is
easy to verify. As for composition, let β : F (cid:48) −→ F (cid:48)(cid:48) and g : C (cid:48) −→ C (cid:48)(cid:48). Then

eval((β, g) ◦ (α, f )) = eval(β ◦ α, g ◦ f )

= F (cid:48)(cid:48)(g ◦ f ) ◦ (β ◦ α)C
= F (cid:48)(cid:48)(g) ◦ F (cid:48)(cid:48)(f ) ◦ βC ◦ αC
= F (cid:48)(cid:48)(g) ◦ βC (cid:48) ◦ F (cid:48)(f ) ◦ αC
= eval(β, g) ◦ eval(α, f )

The third line follows from the functoriality of F (cid:48)(cid:48) and the deﬁnition of composition
of natural transformations; the fourth line is by naturality of β.

For a functor F : B × C −→ D and an object (B, C) of B × C ,

eval ◦ (λF × C )(B, C) = eval ◦ (λF (B), C)

= λF (B)(C) = F (B, C)

468

Solutions for section 6.1

Thus eval ◦ (λF × C ) = F , as required. Similarly, for an arrow (f, g) : (B, C) −→
(B(cid:48), C (cid:48)) of B × C ,

eval ◦ (λF × C )(f, g) = eval ◦ (λF (f ), g)

= λF (B(cid:48))(g) ◦ λF (f )(C)
= F (B(cid:48), g) ◦ F (f, C) = F (f, g)

as required.
2. Let G0 be the set of nodes of G regarded as a graph with no arrows. We must
show that

G0

(cid:161)

(cid:161)

(cid:64)

(cid:64)

()
(cid:64)

(cid:64)(cid:82)

No

i
(cid:161)

(cid:161)(cid:170)

G

is a product diagram, where () is the unique function and i : G0 −→ G is the identity
function on nodes and (necessarily) the empty function on arrows. Let T be a graph
and f : T −→ G , g : T −→ No be graph homomorphisms. We must ﬁnd u : T
−→ G0 for which i ◦ u = f and () ◦ u = (). The second equation is automatic. The
ﬁrst equation requires that u be the same as f on nodes. The fact that there is a
homomorphism from T to No (which has no arrows) means that T has no arrows.
Thus u has to be the empty function on arrows; since f must also be the empty
function on arrows it follows that i ◦ u = f .

A node of G × No as constructed in Exercise 4 of Section 5.1 is a pair (g, n)
where g is a node of G and n is the unique node of No. (The construction in that
exercise shows that G × No has no arrows since No has none.) Thus the function
(g, n) (cid:55)→ g is clearly a bijection between G × No and the set of nodes of G . What we
have constructed here is more than that: it is a natural isomorphism in the category
of graphs.
3. Given f : C × G −→ H , we must show that eval ◦ (λf × G ) = f . First, suppose
that (c, n) is a node of C × G . Then

eval((λf × G )(c, n)) = eval(λf (c), n)

= λf (c)(n) = f (c, n)

For an arrow (a : c −→ d, w) of C × G ,

eval((λf × G )(a, w)) = eval(λf (a), w)

= fa(w) = f (a, w)

as required.

4. Corollary 4.5.13 says that two representing objects for the same functor are
isomorphic by a unique isomorphism that preserves the universal element. Let
φ(A, B) : [A −→ B](cid:48) −→ [A −→ B] be the isomorphism. In this case the functor is
Hom(− × A, B) and preserving the universal element means that

Hom(φ(A, B) × A, B)(eval) = eval ◦ (φ(A, B) × A) = eval(cid:48)
which is the left diagram of the proposition. The right diagram follows from this
calculation: eval ◦ (φ(A, B) × A) ◦ λ(cid:48)f = eval(cid:48)
◦ λ(cid:48)f = f , so by the uniqueness re-
quirement of CCC–3, (φ(A, B) × A) ◦ λ(cid:48)f = λf .

Solutions for section 6.2

469

Section 6.2

1. By CCC–3, eval ◦ ((λ(eval)) × A) = eval : [A −→ B] × A −→ B. By the uniqueness
requirement of CCC-3, (λ(eval)) × A = [A −→ B] × A (the identity arrow) so the
ﬁrst component of (λ(eval) × A) must be the identity.

2. By CCC–3, eval ◦ (λf ×A) ◦ (g ×A) = f ◦ (g ×A). But by 5.2.19, eval ◦ (λf ×A) ◦
(g × A) = eval ◦ ((λf ◦ g) × A). By the uniqueness property of eval, it follows that
λ(f ◦ (g × A)) = (λf ) ◦ g.

3. Since f (cid:55)→ λf is a bijection on each hom set by CCC-3, we only need to show
that the following diagrams is commutative, where g : B −→ B(cid:48).

Hom(C × A, B)

f (cid:55)→ λf

(cid:45)

Hom(C, [A −→ B])

Hom(C × A, g)

Hom(C, [A −→ g])

(cid:63)
Hom(C × A, B(cid:48))

(cid:63)
Hom(C, [A −→ B(cid:48)])

(cid:45)

f (cid:55)→ λf

This requires that λ(g ◦ f ) = [A −→ g] ◦ λf . This follows from CCC–3 and Exercise 2
by the following calculation:

[A −→ g] ◦ λf = λ(g ◦ eval) ◦ λf

= λ(g ◦ eval ◦ (λf × A))
= λ(g ◦ f )

4. Let h : 1 −→ [A −→ B] be a global element. Let u : A −→ 1 × A be an isomorphism
(see Section 5.3). The bijection from Hom(1, [A −→ B]) to Hom(A, B) takes h to

eval ◦ (h × A) ◦ u : A −→ 1 × A −→ [A −→ B] × A −→ B
Its inverse takes f : A −→ B to λ(f ◦ u−1) : 1 −→ [A −→ B], which ﬁts since f ◦
u−1 : 1 × A −→ A −→ B. That this is indeed the inverse follows from CCC–3. (In
categorical writing, these manipulations with u are nearly always suppressed by
assuming that A = A × 1 and u = idA.)
5. In this answer, we regard λ as binding more tightly than composition or product,
so that for example λf ◦ g means (λf ) ◦ g and λf × g means (λf ) × g.

a. Deﬁne ΓB : Hom(C, [A −→ B]) −→ Hom(C × A, B) by ΓB(g) = eval ◦ (g × A).
Then by CCC–3, ΓB ◦ ΛB(f ) = eval ◦ (λf × A) = f for f : C × A −→ B, and by
the uniqueness requirement for eval,

ΛB ◦ ΓB(g) = λ(eval ◦ (g × A)) = g

for g : C −→ [A −→ B], so ΓB is the inverse of ΛB which is therefore bijective.

b. Let g : C (cid:48) −→ C and h : B −→ B(cid:48). Naturality requires that this diagram

commute:

Hom(C, [A −→ B])

(cid:45)(cid:98)hC

Hom(C, [A −→ B(cid:48)])

Hom(g, [A −→ B])

Hom(g, [A −→ B(cid:48)])

(cid:63)
Hom(C (cid:48), [A −→ B])

(cid:63)
Hom(C (cid:48), [A −→ B(cid:48)])

(cid:45)

(cid:98)hC (cid:48)

470

Solutions for section 6.3

Because ΛB is a bijection, an arbitrary arrow of Hom(C, [A −→ B]) can be taken to
be λf for some f : C × A −→ B. The upper route around the diagram takes λf to

λ(h ◦ eval ◦ (λf × A)) ◦ g = λ(h ◦ f ) ◦ g

whereas the lower route takes it to

λ(h ◦ eval ◦ ((λf ◦ g) × A)) = λ(h ◦ eval ◦ (λf × A) ◦ (g × A))

= λ(h ◦ f ◦ (g × A))

which is the same thing by Exercise 2.

c. Let h : B −→ B(cid:48). The required diagram for naturality, namely

Hom(C × A, B)

Hom(C × A, h)

(cid:45)

Hom(C × A, B(cid:48))

ΛB

(cid:63)
Hom(C, [A −→ B])

ΛB(cid:48)
(cid:63)
Hom(C, [A −→ B(cid:48)])

(cid:45)

Hom(C, [A −→ h])

commutes by deﬁnition of [A −→ h]. It is a natural isomorphism because each com-
ponent is a bijection.

d. Let C = [A −→ B] in the preceding diagram and start with eval in the upper
right corner. The upper route gives λ(h ◦ eval) and the lower route gives [A −→ h] ◦
λ(eval), which is [A −→ h] by Exercise 1.

6. We use the formulation of [G −→ H ] in Exercise 3. Let h : 1 −→ [G −→ H ]
be a global element. Remember that in the category of graphs and graph homo-
morphisms, 1 is the graph with one node n and one arrow e. The node n goes to
a node of [G −→ H ], which is a function f0 : G0 −→ H0. The arrow e goes to an
arrow of [G −→ H ], which is an ordered triple (f1, f2, f3) : f1 −→ f2 as described
in Exercise 3. The fact that 1 has only one node means that, since h is a graph
homomorphism, necessarily f1 = f2 = f0. Then the conditions in the description
in Exercise 3 say that for any arrow g of G , source(f3(g)) = f0(source(g)) and
target(f3(g)) = f0(target(g)). Thus f0 must be the node map and f3 the arrow
map of a graph homomorphism from G to H . It follows from Exercise 4 that the
loops of [G −→ H ] are in one to one correspondence with the graph homomorph-
isms from G to H : to recover the homomorphism from the loop (f1, f1, f3) : f1
−→ f1, take the node map to be f1 and the arrow map to be f3.

Section 6.3

1. For i = 1, 2,

proji(c) =X λx∈A×B(proji(x))‘c
=X λx∈A×B(proji(x))‘c(cid:48)
=X proji(c(cid:48))

(TL–17)
(TL–12)
(TL–17)

where in the applications of TL–17, we judiciously choose a variable x of type A × B
that does not occur freely in c or c(cid:48).

Solutions for section 7.1

471

2.

(a, b) =X λx∈A(x, b)‘a
=X λx∈A(x, b)‘a(cid:48)
=X (a(cid:48), b)

(TL–17)
(TL–12)
(TL–17)

and similarly (a(cid:48), b) =X (a(cid:48), b(cid:48)). The result follows from TL–9.

Section 6.4

1. We must show that for f : C × A −→ B, eval ◦ (λf × A) = f . First note that
λf × A = (cid:104)λf ◦ p1, p2(cid:105) : C × A −→ [A −→ B] × A. (See 5.2.17.) Now let z be a
variable of type C, y a variable of type A which is not in X, and suppose f is
determined by a term φ(z, y) of type B. Then λf × A is represented by (λyφ(z, y) ◦
z, y) =X (λyφ(z, y), y) by deﬁnition of composition in C(L ). Then eval ◦ (λf × A)
is

(p1(λyφ(z, y), y))‘p2(λyφ(z, y), y) =X λyφ(z, y)‘y

by TL–15 and Exercise 2 of Section 6.3. Since y /∈ X, this is λyφ(z, y) by TL–18.

2.

Γ(Λ(φ(u))) = Γ(λxφ((z, x)))

= λxφ(proj1 u, x)‘ proj2 u
=X φ((proj1 u, proj2 u))
=X φ(u)

Section 6.5

1. a. N × N

(cid:104)p1, p1, p2, p2(cid:105)
−−−−−−−−−−−→ N × N × N × N ∗ × ∗

−−−−−→ N × N +

b. N × N × N

(cid:104)p1, p1, p3, p2(cid:105)
−−−−−−−−−−−→ N × N × N × N ∗ × ∗

−−→ N
−−−−−→ N × N +

−−→ N

c. N × N

()
−−→ 1

5

−−→ N

Solutions for Chapter 7

Section 7.1

1. Let us temporarily denote the usual addition by ⊕. The fact that 0 + m = m
implies that k + m = k ⊕ m when k = 0. Assuming that equation for some k, we
have that

succ(k) + m = succ(k + m) = succ(k ⊕ m) = succ(k) ⊕ m

2. The cone requires that M (a) = M (a) × M (a). If M (a) is ﬁnite then the number
of elements of M (a) × M (a) is the square of the number of elements of M (a). Hence
M (a) has either no elements or one element or an inﬁnite number.

472

Solutions for section 7.1

To see that S has an inﬁnite model, deﬁne M (a) = N, M (f )(n) = r and
M (g)(n) = s, where (r, s) is the unique pair of nonnegative integers for which n−1 =
2r(2s + 1). It follows from the unique factorization of integers that n (cid:55)→ (r, s) is a
bijection from N to N × N. By Proposition 5.2.3, this means that

M (a)

(cid:161)

M (f )
(cid:161)(cid:170)

(cid:161)

M (a)

(cid:64)

(cid:64)

M (g)
(cid:64)(cid:82)

M (a)

is a product diagram.

3. What we must do is to add an operation and equations to implement the stan-
dard inductive deﬁnition of multiplication: 0 ∗ m = 0 and succ(k) ∗ m = m + k ∗ m.
We do this by adding one operation ∗ : n × n −→ n and diagrams

(cid:104)z, idn(cid:105)

n × n(cid:45)

n

(cid:104)(cid:105)

(cid:63)
1

z

(cid:63)

n(cid:45)

∗

n × n

succ × id

n × n(cid:45)

(cid:104)proj2, proj1, proj2(cid:105)
(cid:63)
n × n × n

n × ∗
(cid:63)
n × n

+

∗

(cid:63)

n(cid:45)

In order to make these diagrams, we also have to add arrows n −→ n × n, n × n
−→ n × n, n × n −→ n × n × n and n × n × n −→ n × n and, following the pattern
of similar constructions in 7.1.7, diagrams forcing them to be (cid:104)z, idn(cid:105), succ × id,
(cid:104)proj2, proj1, proj2(cid:105) and n × ∗ respectively.

Section 7.2

1. If we write xy for M (c)(x, y) for x, y ∈ M (s), then the diagram requires that
xy = x for all x, y ∈ M (s). Then x(yz) = x and (xy)z = xz = x. Of course, most
semigroups do not have such a multiplication, so this sketch is not a sketch for
semigroups.

2. One arrow ∆ : s −→ s × s is needed, with the following diagrams:

s

s × s(cid:45)∆

(cid:64)
idS

(cid:64)

(cid:64)

(cid:64)(cid:82)

c

(cid:63)
s

s

∆

(cid:161)

(cid:161)

(cid:64)

(cid:64)

ids

(cid:64)

ids

(cid:161)

(cid:161)(cid:161)(cid:170)
(cid:190)

s

(cid:63)
s × s

p2

p1

(cid:64)(cid:64)(cid:82)
s(cid:45)

3. We give the answer for the case of real vector spaces; the other is similar. We
assume the real number ﬁeld R as a given structure. We suppose, for each r ∈ R, a

unary operation we will denote r∗ : s −→ s. We require a unit element z : 1 −→ s for
the operation c and a diagram similar to the previous exercise to say that z is the
unit element. The following diagram says that c is commutative:

Solutions for section 7.4

473

(cid:161)

(cid:104)proj2, proj1 0(cid:105)
(cid:161)
(cid:161)(cid:170)

s × s

s × s

(cid:161)

(cid:64)

c

(cid:64)

c
(cid:64)

(cid:64)(cid:82)
s(cid:45)

We have to add a unary negation operator n : s −→ s together with a diagram to
say it is the negation operator:

s

(cid:104)(cid:105)

(cid:63)
1

(cid:104)id, id(cid:105)

s × s(cid:45)

id ×n

(cid:45)

s × s

c

(cid:63)

s(cid:45)

z

In addition, we need diagrams that express the following identities:

0∗(x) = z

r∗(c(x, y)) = c(r∗(x), r∗(y))
(r + s)∗(x) = c(r∗(x), s∗(x))

1∗(x) = x

r∗(s∗(x)) = (rs)∗(x)

We give, for example, the diagram required to express the third of the equations
above:

(cid:104)r∗, s∗(cid:105)

s × s(cid:45)

s

(cid:64)
(cid:64)
(r + s)∗

(cid:64)

(cid:64)

(cid:64)(cid:82)

c

(cid:63)
s

Section 7.4

1. We deﬁne a functor F : Mod(S , Set) −→ Set: Given a model M of S , let
F (M ) = M (s). Given a homomorphism α : M −→ M (cid:48) of models, let F (α) = αs :
M (s) −→ M (s). Deﬁne the inverse G : Set −→ Mod(S , Set) this way: For a set
A, G(A) is the model M with M (s) = A and multiplication M (c) : A × A −→ A
deﬁned by M (c)(a, a(cid:48)) = a. M (p) and M (q) are necessarily the projections and
clearly M (c) = M (p) as required by the lone diagram of S . If φ : A −→ B is a
set function, deﬁne the homomorphism G(φ) : G(A) −→ G(B) by G(φ)s = φ and
G(φ)(s × s) = φ × φ. It is easy to see that this is a homomorphism of models and
that F and G are inverse functors.

474

Solutions for section 7.4

2. Let the functor F : Mod(S , C ) −→ Mod(T , C ) take a model M of S to
the model F (M ) of T that is the same as M on the nodes and arrows with the
same labels, and such that F (M )(c) = M (a) = F (M )(a), F (M )(h) = F (M )(j) =
idF (M )(a) and F (M )(k) = M (f ). Given a natural transformation α : M −→ M (cid:48), let
F (α) have the same components as α on the nodes of S , and set F (α)c = αa.

Deﬁne G : Mod(S , C ) −→ Mod(T , C ) so that G(K) is K restricted to the
nodes and arrows of S . For β : K −→ K (cid:48) deﬁne G(β) to have the same component
as β on a and b.

Then F is an equivalence of categories with pseudoinverse G. G ◦ F is actually
the identity functor on S . The required natural isomorphism η from F ◦ G to the
identity functor on T has ηa = ida, ηb = idb and ηc = h.

Section 7.6

1. It is the model I with I(d) = {a, b} and I(l) = ∅.

2. Let I be the initial model. I(l) contains u, so it contains elements obtained by
repeatedly applying tail to u. Let us write tu for tail(u), t2u for tail(tail(u)), and
so on. The operation head can be applied to each of these, producing a countably
inﬁnite list of elements htnu of I(d), one for each n ∈ N. By the product property,
we then get all possible pairs (htmu, tnu) for m, n ∈ N. These pairs include the
elements tnu because tnu = (htnu, tn+1u). Again by the product property we get
elements (htm1 u, (htm2u, tnu)), (htm1 u, (htm2 u, (htm3u, tnu))) and so on.

This suggests simplifying the notation further as follows: We deﬁne I(l) to be the
set of equivalence classes of ﬁnite sequences s = (s1, s2, s3, . . . , sm) of all possible
nonzero lengths m, with all si ∈ N, using the equivalence relation ∼ generated
by requiring that s ∼ s(cid:48), where s(cid:48) is obtained from s by adjoining sm + 1 as the
m + 1st entry. (Thus (3, 1) ∼ (3, 1, 2) ∼ (3, 1, 2, 3), etc.) We denote the equivalence
class of s by [s]. Note that all elements of an equivalence class have the same ﬁrst
entry and that every equivalence class contains entries of length greater than 1.
Now deﬁne I(d) = N, head([s]) = s1 and tail([s]) the the equivalence class of the
sequence obtained by dropping the ﬁrst entry of a representative of [s] of length
greater than 1.

The only problematical thing to verify is that I(C) is a product cone. Suppose
f : X −→ N and g : X −→ I(l) are given. By deﬁnition of head and tail there is only
one possible map h : X −→ I(l) that makes head ◦ h = f and tail ◦ h = g, and that
is for h(x) to be the equivalence class of the inﬁnite sequence s with s1 = f (x) and
sk = g(x)k−1 for i > 1, and that deﬁnition does indeed work.

To see that I is an initial model, let M be any model. Deﬁne a natural transfor-
mation α : I −→ M as follows. Let I(u) = M (u). If s ∈ [s] has length greater than
1, let s(cid:48) denote the sequence obtained by deleting the ﬁrst entry of s, and deﬁne

αl([s]) = (M (head)(M (tail)s1(M (u))), αl([s(cid:48)]))

This is the only possible deﬁnition for a natural transformation from I to M and
it is easy to prove inductively that it is well-deﬁned and a natural transformation.

Solutions for section 8.1

475

3. Let the elements of X be x and y. Form the set Nx = {(n, x) | n ∈ N} and
similarly Ny = {(n, y) | n ∈ N}. Then S = N ∨ Nx ∨ Ny is certainly the disjoint
union of three copies of N. We can identify x with (0, x) and y with (0, y) so that,
up to isomorphism, x ∈ S and y ∈ S. We deﬁne succ on S by succ(n) = n + 1,
succ(n, x) = (n + 1, x) and succ(n, y) = (n + 1, y). With these deﬁnitions and no
relations, this is the initial term model.

Section 7.7

1. Let the sort on which the operations are deﬁned be σ. Thus ∗ : σ × σ −→ σ and
+ : σ × σ −→ σ. The diagram is then

σ × σ × σ

v = idσ×σ×σ

(cid:45)

σ × σ × σ

(cid:104)idσ, +(cid:105)

σ × σ(cid:45)

w = (cid:104)p1, p2, p1, p3(cid:105)

(cid:63)

σ × σ × σ × σ

σ × σ(cid:45)

∗ × ∗

+

∗
(cid:63)

σ(cid:45)

Solutions for Chapter 8

Section 8.1

1. This should have two sorts 1 and b. There should be an operation true : 1 −→ b,
an operation false : 1 −→ b and a cocone

1

(cid:64)
true

(cid:64)

(cid:64)

(cid:64)(cid:82)

(cid:161)

(cid:161)(cid:170)

1

(cid:161)
false

(cid:161)

b
We need a cone with empty base to express that 1 is terminal. We should have
operations ∨ : b × b −→ b, ∧ : b × b −→ b and ¬ : b −→ b. We will need diagrams to
express equations like

¬ true = false
¬ false = true
¬ ∧ (x, y) = ∨(x, y)

∨(0, 0) = 0
∨(0, 1) = 1
∨(1, 0) = 1
∨(1, 1) = 1

There are other equations, but they all follow from these. In particular, we do not,
in this case, have to express the distributive laws since they follow, there being so
few elements.

476

Solutions for section 8.1

2. If we have one sort 1, one empty cone with vertex 1 and one cocone

1

1

(cid:64)
id

(cid:64)

(cid:64)(cid:82)

1

(cid:161)
id

(cid:161)

(cid:161)(cid:170)

then there is no model in sets because the model must take 1 to the one-element set
and that must satisfy that 1 = 1 + 1, which is impossible. It follows from Exercise 4
of Section 9.6 that this sketch does have a model in the category of monoids.

Section 8.2

1. This is most readily done using elements, although it can all be done with dia-
grams. If x ∗ x−1 = 1 and y ∗ y−1 = 1, then

(x ∗ y) ∗ (y−1 ∗ x−1) = x ∗ (y ∗ (y ∗−1 ∗x−1)) = x ∗ ((y ∗ y−1) ∗ x−1)

= x ∗ (1 ∗ x−1) = x ∗ x−1 = 1

If 2 (cid:54)= 0 in a ﬁeld, then 2−1 exists, whence (2 ∗ 2)−1 = 4−1 also exists. Hence 4 (cid:54)= 0.

2. Let Q and F2 denote the ﬁelds of rational numbers and the two-element ﬁeld
respectively. In order to have a product of Q and F2, we have to have a cone

F

(cid:161)

(cid:64)

(cid:161)

(cid:161)(cid:170)

Q

(cid:64)

(cid:64)(cid:82)

F2

which is exactly what we do not have in the category of ﬁelds.

Section 8.3

1. a. Several things have to be shown. First that the image N0 ⊆ N is closed under
the operations (that is if all the arguments of the operation are in the image, so
does the value); second that the diagrams continue to commute; third that the cones
remain products; and fourth that the cocones remain sums.

Let u : s1 × s2 × · · · × sn −→ s be an operation. For i = 1, . . . , n let xi ∈ M (si)
and x = u(x1, . . . , xn). Then f (x) = u(f (x1), . . . , f (xn)), which demonstrates the
ﬁrst point. Since the operations in N0 are the restrictions of those in N any two
paths that agree on N do so on N0 (actually, whether or not they do on M ). For
the cones, we illustrate on binary cones. Suppose s ←− r −→ t is a cone in the sketch.
Then in the diagram

M (r)

(cid:45)

N0(r)

(cid:45)

N (r)(cid:45)
(cid:63)

(cid:63)(cid:63)
M (s) × M (t)

(cid:45)(cid:45)

(cid:63)

N0(s) × N0(t)

(cid:63)
N (s) × N (t)

(cid:45)

f

Solutions for section 9.1

477

certain functions have been labeled as being surjective or injective (although others
are and some are bijective). These use the facts that the product of two injective
functions is injective and the product of two surjective functions is surjective. That
f is surjective follows from the fact that the composite of two surjective functions
is surjective and if the composite of two functions is surjective, so is the second one.
Dually, the fact that f is injective uses the facts that the composite of two injective
functions is injective and that if the composite of two functions is injective, the ﬁrst
one is.

The dual argument, using the fact that a sum of injectives is injective and a
sum of surjectives is surjective, gives the corresponding result for discrete cocones.
It is worth noting that these arguments fail if either the cones or cocones fail to
be discrete or if the category in which the models are taken is other than the category
of sets. The reason is that even in the category of sets, the arrow induced between
equalizers of epis is not necessarily epic and between coequalizers of monos will not
be monic. (Equalizers and coequalizers are deﬁned in chapter 9.) In categories other
than sets, even the sum of epics will not generally be epic, nor the sums of monics
monic.

b. There are two ways of doing this. One is to show that the intersection of
submodels is a submodel. Then the intersection of all submodels is clearly the
smallest submodel. Another is to take the image of the initial term model in the
component of that model. Let M be the initial term model, N is the given model
and N0 this submodel. If N1 ⊆ N is any other submodel, there is an initial term
model M (cid:48) in the component of N1 that has an arrow M (cid:48) −→ N1. But N1 ⊆ N and
so is in the same component as N . Thus M (cid:48) = M and the map M −→ N1 ⊆ N is
the original map M −→ N . Since that factors through N1, it follows that N0 ⊆ N1.

Solutions for Chapter 9

Section 9.1

1. Let us write 1 for an identity arrow. We claim that f is the equalizer of 1 and
f ◦ g. In fact, f ◦ g ◦ f = f = 1 ◦ f so f ◦ g and 1 equalize f . If h : C −→ B is an
arrow such that f ◦ g ◦ h = 1 ◦ h = h, then g ◦ h : C −→ A satisﬁes f ◦ g ◦ h = h.
Since f is monic, this arrow is unique.

2. Suppose by induction that this is true for every list of n − 1 parallel arrows and
f1, . . . , fn : A −→ B is a list of n parallel arrows. Let j : E −→ A be an equalizer of
f1, . . . , fn−1. We may clearly suppose that n ≥ 3. Then the parallel pair f1 ◦ j, fn ◦
j : E −→ B has an equalizer k : F −→ E. I claim that j ◦ k : F −→ A is an equalizer of
the list. In fact, for i < n, fi ◦ j ◦ k = f1 ◦ j ◦ k, because j simultaneously equalizes
all those arrows, while fn ◦ j ◦ k = f1 ◦ j ◦ k because k equalizes f1 ◦ j and fn ◦ j. If
h : C −→ A is simultaneously equalized by f1, · · · , fn, then there is a unique m : C
−→ E such that j ◦ m = h. Since f1 ◦ j ◦ m = f1 ◦ h = fn ◦ h = fn ◦ j ◦ m, there is a
unique g : C −→ F such that k ◦ g = m. Then j ◦ k ◦ g = j ◦ m = h. If j ◦ k ◦ g(cid:48) = h,
then g(cid:48) = g because j ◦ k is monic; hence g has the required uniqueness property.

478

Solutions for section 9.1

3. Let A and B be monoids and f, g : A −→ B be monoid homomorphisms. Let
E = {x ∈ A | f (a) = g(a)}. Then f (1) = 1 = g(1) so that 1 ∈ E. Also if x, y ∈ E,
then f (xy) = f (x)f (y) = g(x)g(y) = g(xy) so that xy ∈ E and E is a submonoid of
A. Let j : E −→ A be the inclusion homomorphism. Now let h : C −→ A be a monoid
homomorphism with f ◦ h = g ◦ h. Then for all x ∈ C, f (h(x)) = g(h(x)) so that
h(x) ∈ E. Thus h(C) ⊆ E so there is a function k : C −→ E with j ◦ k = h. It has
to be shown that k is a homomorphism, but k(x) = h(x) for all x ∈ C, so that is
trivial. The fact that j is injective makes the uniqueness of k evident.

4. a. For x and y to have an equalizer, we would need, at least, an element z with
xz = yz and this never happens in a free monoid.

b. Suppose the element x is the equalizer of y and z. Then x is monic, which
means, according to the cited exercise, that x is invertible. But then yx = zx implies
that y = yxx−1 = zxx−1 = z.

5. A monomorphism in Set is an injective function (see Theorem 2.8.3), so let f : A
−→ B be an injective function. Let C be the set of all pairs

{(b, i) | b ∈ B, i = 0, 1}

and impose an equivalence relation on these pairs forcing (b, 0) = (b, 1) if and only
if there is an a ∈ A with f (a) = b (and not forcing (b, i) = (c, j) if b and c are
distinct). Since f is injective, if such an a exists, there is only one. Let g : B −→ C
by g(b) = (b, 0) and h : B −→ C by h(b) = (b, 1). Then clearly g(b) = h(b) if and
only if there is an a ∈ A with f (a) = b. Now let k : D −→ B with g ◦ k = h ◦ k. It
must be that for all x ∈ D, there is an a ∈ A, and only one, such that k(x) = f (a).
If we let l(x) = a, then l : D −→ A is the unique arrow with f ◦ l = k.

6. The reason v and w are inverse to each other is that there is no other arrow for
v ◦ u to be but idC and similarly u ◦ v = idD. Let F : A −→ B be the inclusion.
For any functors G, H : B −→ C , if G ◦ F = H ◦ F , then G(u) = H(u). But then

G(v) = G(u−1) = G(u)−1 = H(u)−1 = H(u−1) = H(v)

Since the objects of B and the other arrows are in the image of F , it follows that
G = H. Since F is not an isomorphism, it cannot be a regular monomorphism by
Proposition 9.1.8.

Section 9.2

1. If D is the base of Diagram (9.1), then cone(E, D) is the set of all commutative
cones of that shape. The equalizer of f and g is the universal element of the functor
F of the proof of Proposition 9.1.4. These two functors are naturally isomorphic
by an isomorphism φ : F −→ cone(−, D): if X is any object and u : X −→ A is in
F (X) (so f ◦ u = g ◦ u), then φA(u) is the cone with components u : X −→ A and
f ◦ u : X −→ B. By its very deﬁnition this is a commutative cone, so an element of
cone(X, D). Since u determines f ◦ u uniquely, this function φA is a bijection, so φ
is a natural isomorphism. Since the two functors are isomorphic, so are the objects
that represent them, by the uniqueness of universal elements.

2. The limits are as indicated:

S

(cid:64)

idS

(cid:63)
S

f
(cid:64)
(cid:64)(cid:82)
T(cid:45)

f

proj1
(cid:161)(cid:170)

(cid:161)

S

f

Solutions for section 9.3

479

(cid:64)

proj2
(cid:64)(cid:82)

proj1
(cid:161)(cid:170)

(cid:161)

S

S

f

S × S

(cid:161)

(cid:64)

(cid:63)

(cid:190)

1(cid:45)

(cid:64)

proj2
(cid:64)(cid:82)

S

S ×T S
(cid:64)
(cid:161)

(cid:63)

(cid:190)

T(cid:45)

(a)

(b)

(c)

where S ×T S is the subset {(s, s(cid:48)) | f (s) = f (s(cid:48))} of S × S. (This is standard
notation to be introduced in Section 9.3.)

(cid:81)

i∈I Di is simply a collection of arrows fi : C −→ Di, one
3. a. An arrow f : C −→
for each object of I . In order that it be a commutative cone on the diagram D it is
necessary and suﬃcient that it satisfy the additional condition that Da ◦ fj = fk.
This is equivalent to

projk ◦ f = fk = Da ◦ fj = Da ◦ projj ◦ f

(cid:81)

b. An arrow f : C −→

which is a necessary and suﬃcient condition that f factor through E −→
Di. Thus
a cone over D is equivalent to an arrow to E, which means that E is a limit of D.
Di is a collection of arrows fi : C −→ Di. In order that it
be a commutative cone on D it must simultaneously satisfy the conditions Da ◦ fj =
fk and Db ◦ fl = fm. This is equivalent to (cid:104)fi, fl(cid:105) : C −→ Di × Dl and (cid:104)fk, fm(cid:105) : C
−→ Dk × Dm satisfying (Da × Db) ◦ (cid:104)fj, fl(cid:105) = (cid:104)fk, fm(cid:105), in turn equivalent to r ◦
f = s ◦ f , that is to factoring through E −→

Di.

(cid:81)

(cid:81)

c. Again an arrow f : C −→ A is a family of arrows fi : C −→ Di. In order to
be a commutative cone on D it must satisfy Da ◦ fsource(a) = ftarget(a) for every
arrow a ∈ I . This is exactly the condition that r ◦ f = s ◦ f , which means that f
is a cone over D if and only if it factors through E −→ A. Hence a cone over D is
equivalent to an arrow to E, which means that E is the limit.

Section 9.3

1. Let f : R −→ S and k : R −→ A be functions such that g ◦ f = i ◦ k. Then for
each x ∈ R, g(f (x)) ∈ A which means that f (x) ∈ g−1(A). Thus f factors through
g−1(A) by the corestriction m : R −→ g−1(A) of f to g−1(A), so f = j ◦ m. Also
i ◦ h ◦ m = i ◦ k, so h ◦ m = k because i is monic.
2. Suppose that f : A (cid:41)−→ B is monic. Then the only way you can have g, h : C
−→ A such that f ◦ g = f ◦ h is if g = h. In that case g : C −→ A is the unique arrow
such that id ◦ g = g and id ◦ g = h so that

A

f

(cid:64)

(cid:161)

(cid:161)

(cid:63)

B(cid:45)

(cid:190)

id
(cid:161)
(cid:161)(cid:170)

A

f

(cid:64)

id
(cid:64)
(cid:64)(cid:82)

A

f

480

Solutions for section 9.3

satisﬁes the condition of being a pullback cone. Thus (a) implies (b). It is obvious
that (b) implies (c). Now suppose that the diagram in (c) is a pullback. Let h, k : C
−→ A be arrows such that f ◦ h = f ◦ k. Then we have a cone

C

(cid:64)

(cid:161)

f ◦ h

(cid:63)

B(cid:45)

(cid:190)

(cid:161)

h
(cid:161)
(cid:161)(cid:170)

A

f

(cid:64)

k
(cid:64)
(cid:64)(cid:82)

A

f

so that there is an arrow l : C −→ P such that h = g ◦ l = k. Thus (c) implies (a).

3. Suppose h, k : D −→ P with p2 ◦ h = p2 ◦ k. We have

f ◦ p1 ◦ h = g ◦ p2 ◦ h = g ◦ p2 ◦ k = f ◦ p1 ◦ k

and f is monic by assumption so that p1 ◦ h = p1 ◦ k. Thus x = h and x = k are
solutions to the equation p1 ◦ x = p1 ◦ h and p2 ◦ x = p2 ◦ h. But the deﬁnition of
pullback requires that solution to be unique so that h = k.

4. Let q1 : S × U −→ S and q2 : S × U −→ U be the product projections. Suppose
there are arrows u, v : X −→ P such that (cid:104)p1, p2(cid:105) ◦ u = (cid:104)p1, p2(cid:105) ◦ v. Then

f ◦ p1 ◦ u = f ◦ q1 ◦ (cid:104)p1, p2(cid:105) ◦ u
= f ◦ q1 ◦ (cid:104)p1, p2(cid:105) ◦ v
= f ◦ p1 ◦ v

and similarly g ◦ p2 ◦ u = g ◦ p2 ◦ v so u = v by the uniqueness part of the universal
property of pullbacks.

5. If f, g : A −→ B, then an equalizer is the arrow j : E −→ A in a pullback

E

A(cid:45)j

(cid:104)f, g(cid:105)

(cid:63)
B

(cid:45)

(cid:104)id, id(cid:105)

(cid:63)
B × B

The proof of this fact comes down to showing that any pullback of this square and
an equalizer of f and g represent equivalent functors: the functor G representing a
pullback of the square has value

G(X) = {(u : X −→ A, v : X −→ B) | (cid:104)id, id(cid:105) ◦ v = (cid:104)f, g(cid:105) ◦ u}

= {(u, v) | (cid:104)v, v(cid:105) = (cid:104)f ◦ u, g ◦ u(cid:105)}
= {(u, v) | f ◦ u = v = g ◦ u}
∼= {u | f ◦ u = g ◦ u}

which is the value of the functor representing an equalizer of f and g. (Compare
the proof of Exercise 1 of Section 9.2.)

Solutions for section 9.4

481

6. A pullback of a diagram A −→ 1 ←− B is just a product A × B. We know from
the preceding exercise that a category with products and pullbacks has equalizers.
Hence such a category has ﬁnite products and equalizers. The conclusion now follows
from Corollary 9.2.11.

7. In Set, a pullback is

P = {(a, b) | f (a) = g(b)}

Since f is surjective, for any b ∈ B, there is a a ∈ A such that f (a) = g(b). Then
p2(a, b) = b. Thus p2 is surjective. The condition now follows from Proposition 2.9.2.

8. In the category of monoids, we have seen in 2.9.3 that the inclusion of the
monoid N of nonnegative integers into the monoid Z of integers is an epimorphism.
Let A ⊆ Z denote the submonoid of nonpositive integers. Both inclusions are epic,
but their pullback, which is the intersection, is the submonoid {0} and the maps to
both N and A are not epic. In fact all pairs of arrows on N (or on A) agree on {0}.

9. Suppose the arrow g : A −→ C in Diagram (9.2) is a split epi, so that there is an
arrow h : C −→ A so that g ◦ h = idC. Then we have id : B −→ B and h ◦ f : B −→ A
satisfy f ◦ id = g ◦ h ◦ f so there is an arrow k : B −→ P such that p1 ◦ k = h ◦ f
and p2 ◦ k = idB. This latter identity is what we want.

10. Suppose we have arrows A −→ B and A −→ C giving a commutative cone. By
composing the latter with C −→ D, we get a pair of arrows A −→ B and A −→ D
giving a commutative cone and this leads to a unique arrow A −→ Q. We now have
A −→ C and A −→ Q giving a commutative cone and this leads to a unique arrow A
−→ P making the left hand cone commute. Clearly, the outer rectangle commutes
as well.

It says that the weakest precondition of the composite of two procedures can be
calculated as the weakest precondition under the second procedure of the weakest
precondition under the ﬁrst.

Section 9.4

1. In Exercise 9.1.5 of Section 9.1, we showed that any equalizer is a monomorphism.
Interpreted in the dual category, it is the result of this exercise.

2. By Proposition 2.9.2, every epimorphism in Set is surjective. We claim that every
surjective function is a regular epimorphism. In fact, let f : S −→ T be surjective and
suppose E = {(x, y) ∈ S ×S | f (x) = f (y)}. Let p, q : E −→ S be the ﬁrst and second
projections. We claim that f is the coequalizer of p and q. Clearly f ◦ p = f ◦ q. Let
h : S −→ R such that h ◦ p = h ◦ q. Deﬁne k : T −→ R as follows. For t ∈ T , there is
an s ∈ S with f (s) = t. We would like to deﬁne k(t) = h(s). If s(cid:48) is another element
of S with f (s(cid:48)) = t, then (s, s(cid:48)) ∈ E and so h(s) = (h ◦ p)(s, s(cid:48)) = (h ◦ q)(s, s(cid:48)) =
h(s(cid:48)). Thus k is well deﬁned and clearly k ◦ f = h. The uniqueness of k follows from
the fact that f is epic.

3. In Proposition 9.1.8, it is shown that a regular mono that is an epimorphism is an
isomorphism. The dual says that a monomorphism that is a regular epimorphism
is an isomorphism. In 2.9.3 the inclusion was shown to be epic. Since the inclu-
sion is evidently a monomorphism and not an isomorphism, it cannot be a regular
epimorphism.

482

Solutions for section 9.4

4. We use the terminology of Exercise 2, just assuming that S and T are monoids
and f a monoid homomorphism. First we have to say that if f is not surjective,
then it still may be an epimorphism, as the inclusion of N into Z shows, but it
cannot be regular. The reason is the easily veriﬁed fact that the image of a monoid
homomorphism f : S −→ T is a submonoid T0 ⊆ T and if it is not all of T , the
properties of regular epimorphism and the fact that the inclusion is a monomorphism
combine to provide an arrow T −→ T0 such that the composite T −→ T0 −→ T is the
identity of T . This is possible if and only if T0 = T .

To go the other way, we need add to the construction of Exercise 2 only the
facts that E ⊆ S × S is a submonoid and that all the arrows constructed are monoid
homomorphism. Of all of these, only the fact that k is a monoid homomorphism is
interesting. In fact, if t and t(cid:48) are elements of T and if s, s(cid:48) ∈ S are such that f (s) =
t and f (s(cid:48)) = t(cid:48), then since f is a monoid homomorphism, f (ss(cid:48)) = f (s)f (s(cid:48)) =
tt(cid:48) so that k(tt(cid:48)) = h(ss(cid:48)) = h(s)h(s(cid:48)) = k(t)k(t(cid:48)). Similarly, since f is a monoid
homomorphism, f (1) = 1, so k(1) = h(1) = 1.

5. A kernel pair of f is characterized by the following mapping property: f ◦ d 0 =
f ◦ d 1 and if e0, e1 : C −→ A satisﬁes f ◦ e0 = f ◦ e1, then there is a unique g : C
−→ K such that d i ◦ g = ei, i = 0, 1. Now if f is the coequalizer of e0 and e1 and
the kernel pair exists, let g : C −→ K as described. Suppose h : A −→ D is an arrow
such that h ◦ d 0 = h ◦ d 1. Then h ◦ e0 = h ◦ d 0 ◦ g = h ◦ d 1 ◦ g = h ◦ e1 so that
there is a unique k : B −→ D with k ◦ f = h. Thus f is the coequalizer of d 0 and
d 1.

Section 9.5

1. Suppose E is some object and (cid:104)l|l(cid:48)(cid:105) : C + C (cid:48) −→ E and (cid:104)m|m(cid:48)(cid:105) : B + B(cid:48) −→ E
satisfy (cid:104)l|l(cid:48)(cid:105) ◦ (g + g(cid:48)) = (cid:104)m|m(cid:48)(cid:105) ◦ (f + f (cid:48)). If i and j represent the inclusions of the
components, then by deﬁnition, (cid:104)l|l(cid:48)(cid:105) ◦ (g + g(cid:48)) ◦ i = (cid:104)l|l(cid:48)(cid:105) ◦ i ◦ g = l ◦ g and similarly
(cid:104)m|m(cid:48)(cid:105) ◦ (f + f (cid:48)) ◦ i = m ◦ f so these equations imply that l ◦ g = m ◦ f . By using j
we similarly conclude that l(cid:48) ◦ g(cid:48) = m(cid:48) ◦ f (cid:48). The mapping properties of the pushout
imply the existence of n : D −→ E and n(cid:48) : D(cid:48) −→ E such that n ◦ k = l, n ◦ h = m
n(cid:48) ◦ k(cid:48) = l(cid:48) and n(cid:48) ◦ h(cid:48) = m(cid:48). Then (cid:104)n|n(cid:48)(cid:105) is the required arrow. Uniqueness follows
from the uniqueness of the components, together with the uniqueness of an arrow
from a sum, given its components.
2. a. Since e is injective, e(C) ∼= C. Up to isomorphism, the diagram is the sum of
the following two:

C

C(cid:45)idC

∅

X(cid:45)

f

(cid:63)
A

f

(cid:63)

A(cid:45)

idA

idX
(cid:63)

X(cid:45)

(cid:63)
∅

and the preceding exercise completes the argument.

b. e is an arbitrary monomorphism and the function i is injective.

Solutions for section 9.5

483

3. a. As suggested by the hint, we take pairs of natural numbers with coordinatewise
addition and subject to the relation that for any a ∈ N, (b, c) = (a + b, a + c). This
relation is not an equivalence relation (it is not symmetric because a cannot be
negative), but the symmetric closure is an equivalence relation. We will show that
the quotient is isomorphic to Z. To do this we deﬁne a function f : N × N −→ Z
by f (b, c) = b − c. Clearly, f (a + b, a + c) = f (b, c) so that f ◦ g = f ◦ h. On the
other hand, if f (b, c) = f (b(cid:48), c(cid:48)), then c − b = c(cid:48) − b(cid:48) or c − c(cid:48) = b − b(cid:48). If c ≤ c(cid:48), then
(b, c) = g(c(cid:48) − c, b, c) while (b(cid:48), c(cid:48)) = h(c(cid:48) − c, b, c). If c(cid:48) ≤ c, their roles are reversed.
In either case, f is the quotient by the generated equivalence relation. The function
f is also surjective, since every n ≥ 0 is f (n, 0), while every n < 0 is f (0, −n). Since
f (0, 0) = 0 and f (b + b(cid:48), c + c(cid:48)) = b + b(cid:48) − (c + c(cid:48)) = b − c + b(cid:48) − c(cid:48) = f (b, c) + f (b(cid:48), c(cid:48))
so that f is a monoid homomorphism and the coequalizer is the coequalizer in the
category of monoids.

b. Let us denote this subset by A. The function f : A −→ Z deﬁned by
(cid:110)

f (n, m) =

n
if m = 0
−m if n = 0

is obviously bijective. It is a matter of consideration of cases to see that it is additive
if addition is deﬁned in A as suggested above.

4. Deﬁne h : Z × N+ −→ Q by h(b, c) = b/c. Since b/c = (ab)/(ac), h ◦ f = h ◦ g.
Moreover, if h(b, c) = h(b(cid:48), c(cid:48)), then bc(cid:48) = b(cid:48)c. We have the equations

f (c(cid:48), b, c) = (b, c)
g(c(cid:48), b, c) = (c(cid:48)b, c(cid:48)c)
f (c, b(cid:48), c(cid:48)) = (b(cid:48), c(cid:48))
g(c, b(cid:48), c(cid:48)) = (cb(cid:48), cc(cid:48))

Thus the coequalizer of f and g must render (b, c) and (b(cid:48), c(cid:48)) equal. Thus h is
injective. It is clearly surjective.

5. Let X be a set, r : X −→ B +B(cid:48) and s : X −→ C +C (cid:48) functions such that (h+h(cid:48)) ◦
r = (k + k(cid:48)) ◦ s = v. If we let Y = v−1(D) and Y (cid:48) = v−1(D(cid:48)), then X = Y + Y (cid:48).
Moreover, it is clear that r(Y ) ⊆ B, r(Y (cid:48)) ⊆ B(cid:48), s(Y ) ⊆ C and s(Y (cid:48)) ⊆ C (cid:48). Let
t : Y −→ B and t(cid:48) : Y (cid:48) −→ B(cid:48) be the restrictions of r to Y and Y (cid:48), respectively. Then
r = (cid:104)t|t(cid:48)(cid:105). Similarly, we have s = (cid:104)u|u(cid:48)(cid:105) for u : Y −→ C and u(cid:48) : Y (cid:48) −→ C (cid:48). Moreover,
(h + h(cid:48)) ◦ r = (k + k(cid:48)) ◦ s is equivalent to h ◦ t = k ◦ u and h(cid:48) ◦ t(cid:48) = k(cid:48) ◦ u(cid:48). Since
the original two squares were pullbacks, it follows that there are arrows w : Y −→ A
and w(cid:48) : Y (cid:48) −→ A(cid:48) such that f ◦ w = t, g ◦ w = u, f (cid:48) ◦ w(cid:48) = t(cid:48) and g(cid:48) ◦ w(cid:48) = u(cid:48). This
implies that (f + f (cid:48)) ◦ (cid:104)w|w(cid:48)(cid:105) = (cid:104)t|t(cid:48)(cid:105) = r and (g + g(cid:48)) ◦ (cid:104)w|w(cid:48)(cid:105) = (cid:104)u|u(cid:48)(cid:105) = s. We
also have to show uniqueness, but the arguments are similar.

6. a. e0 : 1 −→ 2 take the single object of 1 to one object of 2 and let e1 take it
to the other. Then to say of a functor u : 2 −→ A that u ◦ e0 = u ◦ e1 is simply
to say that u takes the two objects to the same one. If a is the single arrow in
2, then source(u(a)) = target(u(a)) so that not only will there be u(a), but also
u(a) ◦ u(a) and u(a) ◦ u(a) ◦ u(a) and so on. Now let N also denote the category
with one object and the natural numbers as arrows as deﬁned in the exercise. Then
q(a) ◦ q(a) = 2, q(a) ◦ q(a) ◦ q(a) = 3 and so on. Given a functor u as above, we can

484

Solutions for section 9.5

deﬁne a functor v : N −→ A by v(0) = idsource(u(a)), v(1) = u(a), v(2) = u(a) ◦ u(a)
and so on. Clearly v is unique such that v ◦ q = u. Thus q is the coequalizer of u
and v.

b. In the diagram, the arrow from 1 + 1 to 2 is inclusion and the arrow from
1 + 1 to N is the only possible one. Let v : A −→ 2 and w : A −→ N be such that
q ◦ v = t ◦ w. If f is an arrow in A then q(v(f )) = t(w(f )). But the only integer
that is in the image of q ◦ v and t ◦ w is 0. Thus q(v(f )) = 0, which means that
v(f ) is an identity. Thus v takes every arrow to an identity arrow, that is it factors
through 1 + 1, and the factorization is clearly unique.

The arrow s : 1 + 1 −→ N is not even epic, let alone regular. In fact, t ◦ s = s =

idN ◦ s without t = idN .

c. Let D be the category whose nonidentity arrows can be pictured as:

1

(cid:64)

(cid:161)(cid:181)

(cid:161)

f
(cid:161)

(cid:161)

0

g ◦ f

h

(cid:64)

g
(cid:64)

(cid:64)(cid:82)
(cid:45)
(cid:45)

2

There is a functor G : C −→ D that is like F except that G(h) = h. This functor
cannot factor through F because under any H : 3 −→ D , H(F (h)) = H(g ◦ f ) =
H(g) ◦ H(f ) (cid:54)= h.

d. A complete answer is too long, but we give enough details that the reader
should have no diﬃculty ﬁlling in the rest. The ﬁrst thing to observe is that being
surjective on composable pairs of arrows includes, as special cases, being surjective
on objects and on arrows. Suppose T : A −→ B is a functor which fails to be
surjective on composable pairs, but is surjective on arrows and objects. Let f1 and
g1 be a composable pair of arrows such that whenever T (f2) = f1 and T (g2) = g1,
then f2 and g2 are not composable. Then let S : 3 −→ B be the unique functor such
that S(f ) = f1 and S(g) = g1. The pullback of S along T will be a category that
includes subcategories like C of part (c) of this problem and other pieces. It will
have a functor to the category D of the preceding part that takes every arrow lying
above f to f , every arrow lying above g to g and every arrow lying above g ◦ f to
h, which is not the composite g ◦ f . Then just as in the preceding part, this functor
makes all the identiﬁcations made by the functor to 3, but does not factor through
that functor. Thus that functor is not a regular epi. If T fails to be epi on arrows
or on objects, even easier arguments suﬃce.

For the other direction, in fact a functor that is surjective on composable pairs
of arrows is a stable regular epi (which is more than the problem asked for). It
is immediate that the condition of being surjective on composable pairs is stable
under pullback, so it is suﬃcient to show that such an arrow is a regular epi. The
argument is similar to that for monoids and we omit it.

Section 9.6

1. The functor that assigns to each object the set of commutative cocones to that
object on the base A ←− 0 −→ B is naturally isomorphic to Hom(A, −) × Hom(B, −),
which is the functor which assigns the set of cocones on the discrete base consisting

Solutions for section 9.6

485

of A and B. The isomorphism forgets the arrow 0 −→ A + B and its inverse puts
back the only arrow that can go from 0 to A + B. Thus the universal elements are
isomorphic.

2. Use exactly the same argument as for the preceding exercise.

3. We have to show that if

P1

A(cid:45)p1

P2

A(cid:45)p2

q1

f

q2

f

(cid:63)

C1

(cid:63)

B(cid:45)

g1

(cid:63)

C2

(cid:63)

B(cid:45)

g2

are both pullbacks, then so is

P1 + P2

(cid:104)p1|p2(cid:105)

A(cid:45)

q1 + q2

(cid:63)

C1 + C2

f

(cid:63)

B(cid:45)

(cid:104)g1|g2(cid:105)

Let i1 : C1 −→ C1 + C2, i2 : C2 −→ C1 + C2, j1 : P1 −→ P1 + P2 and j2 : P2 −→ P1 + P2
be the coproduct injections. If a ∈ A and c ∈ C1 + C2 such that f (a) = (cid:104)g1|g2(cid:105)(c),
then either c = i1(c1) for some c1 ∈ C1 and f (a) = g1(c) or c = i2(c2) for some
c2 ∈ C2 and f (a) = g2(c). In the ﬁrst case, there is a unique x1 ∈ P1 such that
p1(x1) = a and q1(x1) = c1. Then also (q1 + q2)(j1(x1)) = j1(q1(x1)) = j1(c1) = c
and (cid:104)p1|p2(cid:105)(j1(x1)) = p1(x1) = a. We get a similar conclusion if c = j2(c2). This
shows that P1 + P2 satisﬁes the existence condition of pullback. The uniqueness
condition is similar.

4. Let us deal ﬁrst with the monoid case. If M is a monoid and f, g : E −→ M are
monoid homomorphisms, then f = g is the function taking the unique element of
e ∈ E to the identity of M . Hence f : E −→ M is the unique monoid homomorphism
such that f ◦ idE = f and f ◦ idE = g. Thus the cocone

E

(cid:64)
idE

(cid:64)

(cid:64)(cid:82)

E

E

(cid:161)
idE

(cid:161)

(cid:161)(cid:170)

is a colimit.

In the category of semigroups, the situation is quite diﬀerent. If f : E −→ S
is a semigroup homomorphism, f (e) need not be an identity arrow, if any exists.
Since e2 = e, it must be that f (e)2 = f (e) (such an element of S is called an
idempotent). Other than that, there is no restriction on what f (e) can be. Now
let S be the semigroup of endofunctions on N. The elements u and v deﬁned in the
problem are idempotents such that for all n, (u ◦ v)n are distinct. In fact, (u ◦ v)n

486

Solutions for section 9.6

adds 2n to odd integers and 2n − 2 to even ones (and (v ◦ u)n does the opposite).
Now let i : E −→ F and j : E −→ F give a sum F = E + E. Let i(e) = a and j(e) = b.
Since there are arrows f, g : E −→ S deﬁned by f (e) = u and g(e) = v, there is an
h : F −→ S such that h ◦ i = f and h ◦ j = g. In F there are all the elements (ab)n
and since h((ab)n) = (u ◦ v)n in order to be a semigroup homomorphism, all the
(ab)n must also be distinct. Thus F is inﬁnite.

5. This follows because they are each isomorphic to E in the previous example.

6. a. The recursive functions are deﬁned as the smallest set of functions including
successor and projections and closed under certain operations, of which the simplest
is composition. (Details are in [Lewis and Papadimitriou, 1981], where recursive
functions are called µ-recursive.) Since the identity is also recursive (it is, for one
thing, the projection from the unary product), it follows that this deﬁnes a category.
b. The ﬁrst thing we do is to choose a bijective pairing with the additional
property that it reﬂects. This means we choose a pair of functions l, r : N −→ N such
that the function (cid:104)l, r(cid:105) : N −→ N × N is bijective and such that if l(m) ≤ l(m(cid:48)) and
r(m) ≤ r(m(cid:48)), then m ≤ m(cid:48). It follows that if l(m) = a, then the number of m(cid:48) ≤ m
for which l(m(cid:48)) = a is r(m). A pairing that works is given by l(m) = exp2(m), the
largest integer l for which 2l divides m, and

r(m) =

m + 1 − 2l
2l+1

where l = l(m). Let Mi be the ith Turing machine in some enumeration of them. Let
M be the process that at step n runs Ml(n) one step. Because of our assumption on
the bijective pairing, this is actually the r(n)th step that this machine has executed.
Deﬁne a recursive function f : N −→ N by letting f (n) = r(n) if machine Ml(n) halts
at the nth step and 0 otherwise. This is not injective (takes the value 0 more than
once) but the composite (cid:104)r, l(cid:105)−1 ◦ (cid:104)id, f (cid:105) is and deﬁnes an injective recursive function
N −→ N whose image is not decidable (else the halting problem would be). But then
there cannot be any recursive function whose image is the complement. Thus the
subobject deﬁned by that injection has no complement in the category.

7. Let N denote the sum of countably many copies of 1 and in : 1 −→ N be the
nth injection to the sum. Let z = n0 : 1 −→ N and let s : N −→ N be deﬁned by
s ◦ in = in+1. Given an object A, an arrow f0 : 1 −→ A and an arrow t : A −→ A,
we use ordinary induction to deﬁne a sequence of arrows fn : 1 −→ A, for n ≥ 1
by fn+1 = t ◦ fn. Then the arrow f = (cid:104)f0, f1, . . . , (cid:105) : N −→ A clearly satisﬁes the
recursion. The uniqueness is shown similarly. If the countable sums are stable under
pullbacks, then this construction is clearly stable.

Section 9.7

1. The deﬁnition of epimorphism implies that for any h : B −→ X, the condition
h ◦ f = h ◦ g is equivalent to the condition h ◦ f ◦ e = h ◦ g ◦ e so that the condition
to be satisﬁed by a coequalizer of f and g is identical to that to be satisﬁed by
a coequalizer of f ◦ e and g ◦ e. Thus the cocone functors are equivalent and are
therefore the universal elements.

Solutions for section 9.8

487

2. If h = (cid:104)h1|h2(cid:105) : B1 + B2 −→ D, then the condition (cid:104)h1|h2(cid:105) ◦ (f1 + f2) = (cid:104)h1|h2(cid:105) ◦
(g1 + g2) is equivalent to the two conditions h1 ◦ f1 = h1 ◦ g1 and h2 ◦ f2 = h2 ◦ g2.
There results unique arrows k1 : C1 −→ D and k2 : C2 −→ D such that k1 ◦ c1 = h1
and k2 ◦ c2 = h2. This gives (cid:104)k1|k2(cid:105) ◦ (c1 + c2) = (cid:104)h1|h2(cid:105).
3. By deﬁnition of coequalizer, e ◦ d0 ◦ u1 = e ◦ d1 ◦ u1, so c ◦ e ◦ d0 ◦ u1 = c ◦ e ◦
d1 ◦ u1, and also c ◦ e ◦ d0 ◦ u2 = c ◦ e ◦ d1 ◦ u2, so by the universal property of
sums, c ◦ e ◦ d0 = c ◦ e ◦ d1. Suppose f ◦ d0 = f ◦ d1. Then f ◦ d0 ◦ u1 = f ◦ d1 ◦ u1,
so there is a unique arrow x : C −→ X for which x ◦ e = f . Since x ◦ e ◦ d0 ◦ u2 =
f ◦ d0 ◦ u2 = f ◦ d1 ◦ u2 = x ◦ e ◦ d1 ◦ u2, there is a unique arrow y : D −→ X for
which y ◦ c = x, hence y ◦ c ◦ e = f . Thus c ◦ e satisﬁes the existence part of the
deﬁnition of coequalizer of d0 and d1. If y(cid:48) ◦ c ◦ e = f , then y ◦ c = y(cid:48) ◦ c since e is
a coequalizer, and so y = y(cid:48) because c is a coequalizer. Thus c ◦ e also satisﬁes the
uniqueness requirement.

Section 9.8

1. Suppose e : A −→ B in E is not an epimorphism. Then the cokernel pair B

f
−−→−−→
g

C

have a common left inverse h : C −→ B and h ◦ f = id ∈ M . If f were in M , the
diagonal ﬁll-in in

A

e

B(cid:45)(cid:45)e

g

(cid:63)
B

(cid:63)

C(cid:45)

f

would provide a map k : B −→ B such that f ◦ k = l. But then k = h ◦ f ◦ k = h ◦
g = id so that f = g which contradicts the assumption that e is not epic.

2. a. Suppose {Ci} is a collection of subobjects of an object C and C0 is an in-
tersection. Suppose ui : Ci −→ C is the inclusion and that vi : C0 −→ Ci is the
element of the limit. Then I claim that each vi is monic. If not, there is some object

f
−−→−−→
g

B and two arrows B

C0 with vi ◦ f = vi ◦ g. Then for each j ∈ I, we have

uj ◦ vj ◦ f = ui ◦ vi ◦ f = ui ◦ vi ◦ g = vj ◦ uj ◦ g from which the monomorphism
vj can be cancelled to give that uj ◦ f = uj ◦ g for all j ∈ I and then g and h are
two arrows to C0 that give the same cone over the diagram D whose limit is C0,
which contradicts the uniqueness of the arrow to the limit. This shows that any
of the equal composites C0 −→ Ci −→ C is monic. If C (cid:48) ⊆ C is any subobject of C
for which C (cid:48) ⊆ Ci for all i, then the universal mapping property of C0 shows that
there is an arrow C (cid:48) −→ C0 such that C (cid:48) −→ C −→ Ci is the inclusion into Ci. If the
composite of two arrows is monic, so is the ﬁrst, so that C (cid:48) −→ C0 is also monic.
Thus C0 is the meet in the poset of subobjects of C.

488

Solutions for section 9.8

b. Consider a category with six objects and eight non-identity arrows as shown

C

(cid:64)
(cid:64)
g
(cid:64)
(cid:64)

h
(cid:64)
(cid:64)
(cid:64)(cid:82)
(cid:64)(cid:82)

A
A

(cid:65)

(cid:72)(cid:72)(cid:72)

(cid:72)

(cid:65)
(cid:65)
(cid:65)

f2

f1

(cid:72)(cid:72)(cid:72)(cid:72)(cid:106)

B0

v1

B1(cid:45)

(cid:65)
(cid:65)
(cid:65)

v2

(cid:65)
(cid:65)(cid:85)
(cid:63)
B2

u1

(cid:63)

B(cid:45)

u2

subobject to u1 ◦ v1 = u2 ◦ v2, u1 ◦ f1 = u2 ◦ f2, f1 ◦ g = f1 ◦ h and f2 ◦ g = f2 ◦ h.
Then the subobjects of B are the four element lattice consisting of B0, B1, B2 and
B and B0 is the meet of B1 and B2. But the lack of an arrow A −→ B0 implies that
B0 is not their intersection. The reason for g and h is so that A is not a subobject
of B.

Solutions for Chapter 10

Section 10.1

1. Add a new unary operation i : c1 −→ c1 and the following diagrams:

c2

(cid:161)

(cid:64)

(cid:104)id, i(cid:105)

(cid:161)

(cid:63)
c2

id
(cid:161)
(cid:161)(cid:170)
(cid:190)

p1

c1

c2

(cid:64)
(cid:161)
(cid:104)i, id 0(cid:105)

(cid:161)

(cid:64)

(cid:64)

i
(cid:64)

(cid:64)(cid:82)
c1(cid:45)

p2

c1

i
(cid:161)

(cid:161)(cid:170)

(cid:63)

c2(cid:45)

p1

id
(cid:64)
(cid:64)(cid:82)
c1(cid:45)

p2

c1

c2(cid:45)(cid:104)id, i(cid:105)
(cid:64)
id

(cid:64)

c1

c

(cid:64)

(cid:64)(cid:82)

(cid:63)
c1

c2(cid:45)(cid:104)i, id 0(cid:105)
(cid:64)
id

(cid:64)

c

(cid:64)

(cid:64)(cid:82)

(cid:63)
c1

2. Let (C0, C1, s, t, u, c) and (D0, D1, s, t, u, c) be two models of the sketch for cat-
egories. Note that we have used the common convention of using the same letter
to stand for the arrow in the sketch and in the model (in every model, in fact). A

Solutions for section 11.1

489

homomorphism consists of an arrow F0 : C0 −→ D0 and an arrow F1 : C1 −→ D1 that
satisfy some conditions forced by the fact that a homomorphism is a natural trans-
formation. First oﬀ, we have s ◦ F1 = F0 ◦ s, t ◦ F1 = F0 ◦ t and u ◦ F0 = F1 ◦ u.
These mean that the homomorphism preserves source, target and identity arrows.
These identities induce a unique arrow F2 : C2 −→ D2 such that p1 ◦ F2 = F1 ◦ p1
and p2 ◦ F2 = F1 ◦ p2. We further suppose that c ◦ F2 = F1 ◦ c. These conditions
mean that the homomorphism preserves composition; thus the homomorphism is a
functor.

Section 10.2

1. Referring to Diagram (10.1), we see that incl is the arrow opposite not ◦ true : 1
−→ b in a cone, which means that in a model it is the arrow opposite an arrow from
1. But every arrow from 1 is monic (see Section 2.8, Exercise 7). Hence incl is monic.

Section 10.3

1. It is the set of all diagrams (not necessarily commutative) of the form

A

B(cid:45)f

g(cid:64)

(cid:64)

(cid:64)(cid:82)

h
(cid:63)
C

2. It is the set of all commutative diagrams of the form

A

B(cid:45)f

g(cid:64)

(cid:64)

(cid:64)(cid:82)

h
(cid:63)
C

3. For each object C of C , let M (cid:48)(c) = {(x, c) | x ∈ M (c)}. If t : c −→ d is an arrow
in S , let t(x, c) = (t(x), d). Then the ﬁrst projection is an isomorphism M (cid:48) −→ M
and it is clear that M (c) ∩ M (d) = ∅ for c (cid:54)= d.

Solutions for Chapter 11

Section 11.1

1. A model of E is a sketch homomorphisms E −→ C . This assigns to the single
node of E an object E and that is all. If we denote the single object of E by
w, then the functor M (cid:55)→ M (e) is evidently an isomorphism between the objects
of C and those of Mod(E , C ). If α : M −→ N is a natural transformation, the
αe : M (e) −→ N (e) is an arrow of C and is subject to no conditions. Thus means
that Nat(M, N ) = Hom(M (e), N (e)) and so the functor is an isomorphism.

490

Solutions for section 11.2

Section 11.2

1. Nat has one such node, denoted 1, as does Stack. The disjoint union has two
such nodes, but when the coequalizer is formed they are identiﬁed to a single node
in S . This node, and only this, must become a singleton in any model.

Section 11.3

1. U × U is induced by the sketch homomorphism from E to the sketch for monoids
(given in 7.2.1 and 7.3.2) that takes e to s × s.

2. For any u : s1 −→ s2 in S , we have F (u) : F (s1) −→ F (s2) which gives a com-
mutative square

M (F (s1))

M (F (u))

(cid:45)

M (F (s2))

αF (s1)

(cid:63)
N (F (s1))

αF (s2)

(cid:45)

(cid:63)
N (F (s2))

N (F (u))

which is the same as

F ∗(M )(s1)

F ∗(M )u

(cid:45)

F ∗(M )(s2)

F ∗(α)s2

F ∗(N )u

(cid:63)
F ∗(N )(s1)

(cid:45)

(cid:63)
F ∗(N )(s2)

F ∗(α)s2

which is naturality of F ∗(M ).
3. We have for idS : S −→ S that (idS )∗(M ) = M ◦ idS = M and for α : M
−→ N , (idS )∗(α) = α idS = α. Thus (idS )∗ is the identity functor. If G : R −→ S
is another homomorphism of sketches, then (F ◦ G)∗(M ) = M ◦ F ◦ G = G∗(M ◦
F ) = G∗(F ∗(M )) = (G∗ ◦ F ∗)(M ) and similarly for α : M −→ N . Thus (F ◦ G)∗ =
G∗ ◦ F ∗ which shows that ModC (−) is a contravariant functor.
4. Suppose, say, that σ is a diagram. The other two possibilities are similar. Suppose
σ says that

Then σ is satisﬁed in F ∗(M ) if and only if

s1 ◦ · · · ◦ sn = t1 ◦ · · · ◦ tm

F ∗(M )(s1) ◦ · · · ◦ F ∗(M )(sn) = F ∗(M )(t1) ◦ · · · ◦ F ∗(M )(tm)

which is the same as

M (F (s1)) ◦ · · · ◦ M (F (sn)) = M (F (t1)) ◦ · · · ◦ M (F (tm))

which is the same as the condition that M satisfy F (σ).

Solutions for section 12.1

491

Solutions for Chapter 12

Section 12.1

1. Let EC be the ﬁber over an object C. If X is an object of EC, then P (X) = C
and P (idX ) = idC by deﬁnition of functor It follows that idX is an arrow of EC.
If f : X −→ Y and g : Y −→ Z are arrows of EC, then P (f ) = P (g) = idC, so
P (g ◦ f ) = P (g) ◦ P (f ) = idC ◦ idC = idC, so g ◦ f is an arrow of EC. Hence EC is
a subcategory.

2. Let P : E −→ C be a ﬁbration with cleavage γ. To see that F f is a functor, note
ﬁrst that γ(f, Y ) ◦ idY = idY ◦ γ(f, Y ) so that F f (idY ) = idF fY . Suppose u(cid:48) : Y (cid:48)
−→ Y (cid:48)(cid:48). Then

γ(f, Y (cid:48)(cid:48)) ◦ F f (u(cid:48)) ◦ F f (u) = u(cid:48) ◦ γ(f, Y (cid:48)) ◦ F f (u) = u(cid:48) ◦ u ◦ γ(f, Y )

so by uniqueness F f (u(cid:48) ◦ u) = F f (u(cid:48)) ◦ F f (u).

Now we show that F is a contravariant functor. If we show that F (idC) is the
identity on arrows it will have to be the identity on objects because functors preserve
source and target. Let C be an object of C and u an arrow of F (C). Then F (idC)(u)
is the unique arrow for which γ(idC, Y (cid:48)) ◦ F (idC)(u) = u ◦ γ(idC, Y ). By SC–1, this
requirement becomes idY (cid:48) ◦ F (idC)(u) = u ◦ idY . Thus F (idC)(u) = u as required.
Now suppose f : C −→ D and g : D −→ E in C . Let u : Y −→ Y (cid:48) in F (C). Then

F (g ◦ f )(u) must be the unique arrow for which

γ(g ◦ f, Y (cid:48)) ◦ F (g ◦ f )(u) = u ◦ γ(g ◦ f, Y )

But

u ◦ γ(g ◦ f, Y ) = u ◦ γ(g, Y ) ◦ γ(f, F f (Y ))

= γ(g, Y (cid:48)) ◦ F g(u) ◦ γ(f, F f (Y ))
= γ(g, Y (cid:48)) ◦ γ(f, F f (Y (cid:48))) ◦ F f (F g(u))

so by CA–2 and SC–2, F (g ◦ f ) = F (f ) ◦ F (g).

3. a. We will also denote the functor by φ. It is a ﬁbration if for every element x
of Z2 there is an element u of Z4 such that φ(u) = x (that is CA–1) and for every
v ∈ Z4 and h ∈ Z2 such that x + h = φ(v) (mod 2), there is a unique w ∈ Z4 for
which φ(w) = h and u + w = v (mod 4) (which is CA–2). This amounts to saying
that φ is surjective and every equation m + y = n (mod 4) can be solved uniquely
for y, which requires simple case checking (or knowing that Z2 and Z4 are groups).
An analogous proof works for opﬁbration.

b. A splitting would be a monoid homomorphism (this follows immediately
from SC–1 and SC–2) which would make φ a split epimorphism, which it is not by
Exercise 2 of Section 2.9.

4. a. P preserves source and target by deﬁnition. Let (h, k) : f −→ f (cid:48) and (h(cid:48), k(cid:48)) : f (cid:48)
−→ f (cid:48)(cid:48). Then

P ((h(cid:48), k(cid:48)) ◦ (h, k)) = P (h(cid:48) ◦ h, k(cid:48) ◦ k) = k(cid:48) ◦ k = P (h(cid:48), k(cid:48)) ◦ P (h, k)

492

Solutions for section 12.1

Thus P preserves composition. The identity on an object (A, B) is (idA, idB), so it
follows immediately that P preserves identities.

b. Let f : C −→ D in C and let k : B −→ D be an object of A lying over D.
Let γ(f, k) be the arrow (u, f ) of A deﬁned in 12.1.5. P (γ(f, k)) = f so CA–1 is
satisﬁed. As for CA–2, let (v, v(cid:48)) : z −→ k in A and let h be an arrow of C such
that f ◦ h = v(cid:48). Let w be the unique arrow given by the pullback property for which
u ◦ w = v and u(cid:48) ◦ w = h ◦ z. The last equation says that (w, h) is an arrow of A ,
and (u, f ) ◦ (w, h) = (u ◦ w, f ◦ h) = (v, v(cid:48)) as required. The uniqueness property of
the pullback means that (w, h) is the only such arrow.

Section 12.2

1. The identity arrow for (x, C) is (x, idC). Let (x, f ) : (x, C) −→ (x(cid:48), C (cid:48)), (x(cid:48), f (cid:48)) :
(x(cid:48), C (cid:48)) −→ (x(cid:48)(cid:48), C (cid:48)(cid:48)) and (x(cid:48)(cid:48), f (cid:48)(cid:48)) : (x(cid:48)(cid:48), C (cid:48)(cid:48)) −→ (x(cid:48)(cid:48)(cid:48), C (cid:48)(cid:48)(cid:48)) be arrows of G0(C , F ).
Then ((x(cid:48)(cid:48), f (cid:48)(cid:48)) ◦ (x(cid:48), f (cid:48))) ◦ (x, f ) = (x(cid:48)(cid:48), f (cid:48)(cid:48) ◦ f (cid:48)) ◦ (x, f ) = (x(cid:48)(cid:48), (f (cid:48)(cid:48) ◦ f (cid:48)) ◦ f ) =
(x(cid:48)(cid:48), f (cid:48)(cid:48) ◦ (f (cid:48) ◦ f )) = (x(cid:48)(cid:48), f (cid:48)(cid:48)) ◦ ((x(cid:48), f (cid:48)) ◦ (x, f )) so composition is associative.

2. Let f : C −→ C (cid:48) in C . Let (x, C) be an object of G0(C , F ) lying over C. Deﬁne
κ(f, (x, C)) to be (x, f ) : (x, C) −→ (x(cid:48), C (cid:48)) where x(cid:48) = F f (x). Now suppose (x, g) :
(x, C) −→ (y, C (cid:48)(cid:48)) and suppose k : C (cid:48) −→ C (cid:48)(cid:48) has the property that k ◦ f = g. The
arrow required by OA–2 is (x(cid:48), k) : (x(cid:48), C (cid:48)) −→ (y, C (cid:48)(cid:48)). This is well deﬁned since
F k(x(cid:48)) = F k(F f (x)) = F (k ◦ f )(x) = F g(x) which must be y since (y, C (cid:48)(cid:48)) is the
given target of (x, g). Moreover it satisﬁes OA–2 since (x(cid:48), k) ◦ (x, f ) = (x, k ◦ f ) =
(x, g). An arrow satisfying OA–2 must lie over k and have source (x(cid:48), C (cid:48)) and target
(y, C (cid:48)(cid:48)) so that it can compose with f to give g, so (x(cid:48), k) is the only possible
such arrow. To see that κ is a splitting, suppose that (x(cid:48), f (cid:48)) : (x(cid:48), C (cid:48)) −→ (x(cid:48)(cid:48), C (cid:48)(cid:48)).
Then κ(f (cid:48), (x(cid:48), C (cid:48))) = (x(cid:48), f (cid:48)) and (x(cid:48), f (cid:48)) ◦ (x, f ) = (x, f (cid:48) ◦ f ) = κ(f (cid:48) ◦ f, (x, C)) as
required. The veriﬁcation for identities is even easier.

3. The identity arrow is (idx, idC) : (x, C) −→ (x, C). It is well deﬁned since F (idC)(x) =
x, so idx : F (idC)(x) −→ x. Suppose that (u, f ) is an arrow from (x, C) to (x(cid:48), C (cid:48)),
so that u : F f (x) −→ x(cid:48). Similarly, let (u(cid:48), f (cid:48)) : (x(cid:48), C (cid:48)) −→ (x(cid:48)(cid:48), C (cid:48)(cid:48)) and (u(cid:48)(cid:48), f (cid:48)(cid:48)) :
(x(cid:48)(cid:48), C (cid:48)(cid:48)) −→ (x(cid:48)(cid:48)(cid:48), C (cid:48)(cid:48)(cid:48)). Then

((u(cid:48)(cid:48), f (cid:48)(cid:48)) ◦ (u(cid:48), f (cid:48))) ◦ (u, f ) = (u(cid:48)(cid:48), F f (cid:48)(cid:48)(u(cid:48)), f (cid:48)(cid:48) ◦ f (cid:48)) ◦ (u, f )

= (u(cid:48)(cid:48) ◦ F f (cid:48)(cid:48)(u(cid:48)) ◦ F (f (cid:48)(cid:48) ◦ f (cid:48))(u), (f (cid:48)(cid:48) ◦ f (cid:48)) ◦ f )

and

(u(cid:48)(cid:48), f (cid:48)(cid:48)) ◦ ((u(cid:48), f (cid:48)) ◦ (u, f )) = (u(cid:48)(cid:48), f (cid:48)(cid:48)) ◦ (u(cid:48) ◦ F f (u), f (cid:48) ◦ f )

= (u(cid:48)(cid:48) ◦ F f (cid:48)(cid:48)(u(cid:48) ◦ F f (cid:48)(u)), f (cid:48)(cid:48) ◦ (f (cid:48) ◦ f ))

The result follow from the facts that F and F f (cid:48)(cid:48) are functors and composition in
C is associative.

4. Let f : C −→ C (cid:48) and let (x, C) lie over C. Deﬁne κ(f, (x, C)) to be

(idF f (x), f ) : (x, C) −→ (F f (x), C (cid:48))

Solutions for section 12.3

493

Let (u, g) : (x, C) −→ (y, C (cid:48)(cid:48)) so that u : F g(x) −→ y. Let k : C (cid:48) −→ C (cid:48)(cid:48) satisfy k ◦
f = g. Then (u, k) : (F f (x), C (cid:48)) −→ (y, C (cid:48)(cid:48)) because the domain of u is F g(x) =
F (k ◦ f )(x) = F (k)(F f (x)). Furthermore,

(u, k) ◦ (idF f (x), f ) = (u ◦ F (idF f (x)), k ◦ f ) = (u, g)

as required by OA–2. It follows as in the answer to the second problem that (u, k)
is the only possible arrow with this property.

5.

and

((t, m)(t(cid:48), m(cid:48)))(t(cid:48)(cid:48), m(cid:48)(cid:48)) = (tα(m, t(cid:48)), mm(cid:48))(t(cid:48)(cid:48), m(cid:48)(cid:48))

= (tα(m, t(cid:48))α(mm(cid:48), t(cid:48)(cid:48)), mm(cid:48)m(cid:48)(cid:48))

(t, m)((t(cid:48), m(cid:48))(t(cid:48)(cid:48), m(cid:48)(cid:48))) = (t, m)(t, α(m(cid:48), t(cid:48)(cid:48)), m(cid:48)m(cid:48)(cid:48))

= (tα(m, t(cid:48)α(m(cid:48), t(cid:48)(cid:48))), mm(cid:48)m(cid:48)(cid:48))

However, by MA–4,

α(m, t(cid:48))α(mm(cid:48), t(cid:48)(cid:48)) = α(m, t(cid:48))α(m, α(m(cid:48), t(cid:48)(cid:48)))

and that is α(m, t(cid:48)α(m(cid:48), t(cid:48)(cid:48))) by MA—2.

6. Let β take an object x of F (C) to (x, C) and an arrow u to (u, idC). By GC–3,
if v : y −→ z then

(v, idC) ◦ (u, idC) = (v ◦ F (idC)(u), idC ◦ idC) = (v ◦ u, idC)

so β preserves composition. It is clearly a bijection and preserves identities.

Section 12.3

1. Suppose that α : F −→ G is a natural transformation. Gα preserves identities
because Gα(idX , idC) = αC(idX , idC) = (idαC(x), idC). Suppose that (u, f ) : (x, C)
−→ (x(cid:48), C (cid:48)) and (u(cid:48), f (cid:48)) : (x(cid:48), C (cid:48)) −→ (x(cid:48)(cid:48), C (cid:48)(cid:48)). Then

(u(cid:48), f (cid:48)) ◦ (u, f ) = (u(cid:48) ◦ F f (cid:48)(u), f (cid:48) ◦ f )

by GC–3 (Section 12.2). On the other hand,

Gα(u(cid:48), f (cid:48)) ◦ Gα(u, f ) = (αC (cid:48)(cid:48)u(cid:48), f (cid:48)) ◦ (αC (cid:48)u, f )

= (αC (cid:48)(cid:48)u(cid:48) ◦ Gf (cid:48)(αC (cid:48)u), f (cid:48) ◦ f )
= (αC (cid:48)(cid:48)u(cid:48) ◦ αC (cid:48)(cid:48)(F f (cid:48)(u)), f (cid:48) ◦ f )
= (αC (cid:48)(cid:48)(u(cid:48) ◦ F f (cid:48)(u)), f (cid:48) ◦ f )
= Gα(u(cid:48) ◦ F f (cid:48)(u), f (cid:48) ◦ f )

where the third equality uses the naturality of α and the fourth uses the fact that
αC (cid:48)(cid:48) is a functor. Thus Gα preserves composition.

494

Solutions for section 12.4

2. GR–2 implies that G preserves identity natural transformations, since any com-
ponent of an identity transformation is an identity arrow. Let α : F −→ F (cid:48) and
β : F (cid:48) −→ F (cid:48)(cid:48) be natural transformations, where F , F (cid:48) and F (cid:48)(cid:48) are functors from C
to Cat. Then for (u, f ) : (x, C) −→ (x, C (cid:48)),

G(β ◦ α)(u, f ) = ((β ◦ α)C (cid:48)u, f ) = (βC (cid:48)(αC (cid:48)u), f )

and

(Gβ(Gα))(u, f ) = Gβ(αC (cid:48)u, f ) = (βC (cid:48)(αC (cid:48)u), f )

so G preserves composition.

Section 12.4

1. If A and B are monoids, then each has only one object. By WP–1, an object
of A wrG B is a pair (A, P ) where A is the only object of A and P : G(A) −→ B
is a functor. But if B has only one object and G(A) is discrete, there is only one
functor from G(A) to B – it must take all the objects of G(A) to the only object
of B. Hence A wrG B has only one object, so is a monoid.

2. Let A and B be groups. Since they have only one object each, we can simplify
the notation in WP–1 through WP–3 and omit mention of the objects A, A(cid:48) and
A(cid:48)(cid:48). The value of G at the only object of A is a category we will call G . If f is
an element of the group A , then Gf is an automorphism of the category G . An
object of A wrG B is a functor P : G −→ B. An arrow (f, λ) : P −→ P (cid:48) consists
of an element f of the group A and a natural transformation λ : P −→ P (cid:48) ◦ Gf .
Each component of λ is an element of the group B so has an inverse; thus λ is an
invertible natural transformation. Since f is also a group element, it has an inverse
f −1. Let µ be the natural transformation whose component at an object X of G
is (λ(Gf )−1(X))−1. Then the inverse of the arrow (f, λ) is (F −1, µ). To verify this,
we calculate

(F −1, µ) ◦ (f, λ) = (f −1 ◦ f, µGf ◦ λ)

Now F −1 ◦ f is the identity of A and for an object X of G ,

(µGf ◦ λ)X = µ(Gf (X)) ◦ λX

= λ((Gf )−1(Gf (X)))−1 ◦ λX
= (λX)−1 ◦ λX = idX

so (f, λ) is invertible.

Solutions for Chapter 13

Section 13.1

1. By deﬁnition, g takes the identity of F (X) to that of M . If a = (x1, . . . , xn) and
b = (y1, . . . , ym), then ab = (x1, . . . , xn, y1, . . . , ym) and

Solutions for section 13.2

495

g(ab) = g(x1, . . . , xn, y1, . . . , ym)

= u(x1) · · · · · u(xn) · u(y1) · · · · · u(ym)
= g(x1, . . . , xn) · g(y1, . . . , ym)
= g(a) · g(b)

Section 13.2

1. If S0 ⊆ f −1(T0), let y ∈ f (S0). Then there is some x ∈ S0 such that f (x) = y and
since x ∈ S0 ⊆ f −1(T0), x ∈ f −1(T0) so that y = f (x) ∈ T0. Therefore f∗(S0) ⊆ T0.
Conversely, suppose f∗(S0) ⊆ T0. For x ∈ S0, f (x) ∈ F (S0) so that f (x) ∈ T0,
whence x ∈ f −1(T0). Therefore S0 ⊆ f −1(T0).

2. Let Σ ∆. Then for every object C,

HomC (Σ(A, B), C) ∼= HomC ×C ((A, B), ∆(C))
∼= HomC ×C ((A, B), (C, C))
∼= HomC (A, C) × HomC (B, C)

which is the mapping condition that determines A + B uniquely.

3. The unit of the adjunction is the map from ∆Π(A, B) −→ (A, B) that cor-
responds under the adjunction to the identity arrow Π(A, B) −→ Π(A, B). Since
Π(A, B) = A × B, we are looking for an arrow (A × B, A × B) −→ (A, B). The arrow
is (proj1, proj2) since that is the pair that gives the universal mapping property.
4.
If n is an integer, let us (temporarily) denote by coe(n) (for coercion), the real
number n. If there is a left adjoint, say ci, then it is characterized by the property
that for all real n ∈ N and r ∈ R, ci(r) ≤ n if and only if r ≤ coe(n), the property
that obviously characterizes the ceiling function. In a similar way the right adjoint
ﬂ is characterized by the property that n ≤ ﬂ(r) if and only if coe(n) ≤ r, which is
the deﬁning property of the ﬂoor function.

5. There is a sketch for monoids gotten by augmenting that of semigroups given in
Section 7.2 by adding a constant of type s and diagrams that force it to be a left
and right identity. Call this sketch M . For a set X, let M (X) denote the sketch
gotten from M by adding to M the set X of constants. Then the initial algebra
for M (X) is just the free monoid F (X). The reason is that a model of M (X) is
just a model M of M together with a chosen element u(x) ∈ M for each x ∈ X,
which is just a function u : X −→ U (M ). Thus an initial model of the sketch is the
free monoid generated by X. In 4.7.17, exactly the same construction of adding a
set of constants to a sketch and forming the initial model yields the free model on
the original sketch generated by that set.

6. This is the content of Proposition 3.1.15.

496

Solutions for section 13.2

7. Exercise 10 of Section 3.1 says that the discrete category has the unique map
lifting property, so the functor that takes a set to the discrete category with that set
of objects is the left adjoint. Similarly by Exercise 11 of Section 3.1, the construction
of the indiscrete category gives the right adjoint.

8. Given a set S, the value of the left adjoint is the category with object set S ×{s, t}
and arrow set S ×{1, 2, 3}. If f ∈ S then (f, 1) : (f, s) −→ (f, t), (f, 2) : (f, s) −→ (f, s)
and (f, 3) : (f, t) −→ (f, t), with (f, 2) and (f, 3) acting as identity arrows. There are
no other compositions.

There is no right adjoint by Theorem 13.3.7, since by Exercise 6 of Section 9.5,

the underlying arrow functor does not preserve coequalizers.

9. If the functor deﬁned in 13.2.5 has a left adjoint F , then by deﬁnition of left
adjoint there is for any set X an arrow ηX : X −→ F X × A with the property
that for any function f : X −→ Y × A there is a unique function g : F X −→ Y for
which (g × A) ◦ ηX = f . Now take Y = 1, the terminal object (any one element
set). There is only one function g : F X −→ 1, so there can be only one function
f : X −→ 1 × A ∼= A. If A has more than one element and X is non-empty, this is a
contradiction.

10. Since it is the arrow that corresponds under adjunction to the identity, its value
at B is the unique arrow ηB : B −→ RA(B × A) such that the composite

B × A

ηB × idA

−−−−−−−−→ RA(B × A) × A

e

−→ B × A

is the identity. In Set, RA(B × A) is the set of functions from A to A × B, and ηB
takes b ∈ B to the function a (cid:55)→ (b, a).

Section 13.3

1. We use Theorem 13.3.2. We have

HomA (LT A, A(cid:48)) ∼= HomB(T A, T A(cid:48)) ∼= HomA (A, RT A(cid:48))

and

HomB(T LB, B(cid:48)) ∼= HomA (LB, RB(cid:48)) ∼= HomB(B, T RB(cid:48))
2. a. A limit of the inclusion X ⊆ R is a real number r such that r ≤ x for all
x ∈ X (that is the cone with vertex r) and that if r(cid:48) ≤ x for all x ∈ X, then r(cid:48) ≤ r.
This is precisely the deﬁnition of the inﬁmum. The second half is dual.

b. Since the ﬂoor function is a right adjoint, it preserves all limits that exist,
in particular, all inﬁmums and dually the ceiling function preserves colimits, which
includes supremums. On the other hand, if we take, say a sequence that converges
downwards on an integer, say the sequence X = 1, 1/2, . . . , 1/n, . . . the inﬁmum of
the ceilings is 1, while the inﬁmum is 0, whose ceiling is 0. Similarly, ﬂoor does not
necessarily preserve supremum.

3. This translates to showing for any g : A(cid:48) −→ A and h : B −→ B(cid:48), that

Solutions for section 13.3

497

Hom(F A, B)

β(A, B)

(cid:45)

Hom(A, U B)

Hom(F g, h)

Hom(g, U h)

(cid:63)
Hom(F A(cid:48), B(cid:48))

(cid:63)
Hom(A(cid:48), U B(cid:48))

(cid:45)

β(A(cid:48), B(cid:48))

Applied to an f ∈ Hom(F A, B), this requires that we show that

U (h ◦ f ◦ F g) ◦ ηA(cid:48) = U h ◦ (U f ◦ ηA) ◦ g

But using the functoriality of U and naturality of η, we have

U (h ◦ f ) ◦ ηA(cid:48) = U h ◦ U f ◦ U F g ◦ ηA(cid:48) = U h ◦ U f ◦ ηA ◦ g

4. The adjointness F
natural isomorphism

U , for F : C −→ D and U : D −→ C is equivalent to the

HomC (−, U −) ∼= HomD (F −, −) : C op × D −→ Set

But that is the same as the natural isomorphism

HomC op(U op−, −) ∼= HomD op(−, F op−) : D × C op −→ Set

and since (D op)op = D , the conclusion follows.

5. a. Here and below, we use Hom for HomC and HomA for HomC /A. If f : B −→ A
is an object of C /A and C is an object of C , an arrow g : f −→ PA(C) = p2 : C × A
−→ A has two coordinates, say g1 = p1 ◦ g : B −→ C and g2 = p2 ◦ g : B −→ A. It
is an arrow in C /A if and only if g2 = f . Thus there are no conditions on g1, so
HomA(f, PA(C)) ∼= Hom(B, C) = Hom(LA(f ), C).

b. This is an application of Exercise 1.
c.

Hom(B, Φ(PA(C))) ∼= Hom(B, [A −→ C]) ∼= Hom(B × A, C)
∼= HomA(B × A −→ A, C × A −→ A) ∼= HomA(PA(B), PA(C))

d. The hint suggests that we ﬁnd a natural transformation from Hom(−, Φ(C))
to Hom(−, Φ(D)). It is simple to prove that the isomorphism of part (c) is natural
in B. Thus we have for any B, the arrow

Hom(B, Φ(PA(C))) ∼= Hom(PA(B), PA(C))
Hom(PA(B), f )
−−−−−−−−−−−−−→ Hom(PA(B), PA(D)) ∼= Hom(B, Φ(PA(D)))

The fact that these isomorphisms are natural in B implies the existence of the
required arrow Φ(f ). The desired commutation is essentially the deﬁnition. This
part justiﬁes the use of the notation Φ(PA(C)) for it implies that if PA(C) ∼= PA(D),
then Φ(PA(C)) ∼= Φ(PA(D)).

498

Solutions for section 13.3

e. The required diagram is given by letting d = (cid:104)idC, f (cid:105) : C −→ C × A, d 0 =
(cid:104)proj1, proj2, proj2(cid:105) and d 1 = (cid:104)proj1, f ◦ proj1, proj2(cid:105) : C × A −→ C × A × A. These
are readily seen to be arrows in C /A. The equalizer of d 0 and d 1 is

{(c, a) ∈ C × A | (c, a, a) = (c, f (c), a)}
= {(c, a) ∈ C × A | a = f (c)} = {(c, f (c)) | c ∈ C}

which is the image of d.
f. In the diagram

Hom(B, Φ(f ))

(cid:45)

Hom(B, Φ(PA(C)))

(cid:45)(cid:45)

Hom(B, Φ(PALAPA(C)))

(cid:63)

HomA(PA(B), f )

∼=
(cid:63)
HomA(PA(B), PA(C))

∼=
(cid:63)
HomA(PA(B), PALAPA(C))

(cid:45)(cid:45)

(cid:45)

both lines are equalizers since both Hom(B, −) and HomA(PA(B), −) preserve
equalizers. Moreover the middle and right hand vertical arrows are isomorphisms by
part (c) and by deﬁnition. Hence by uniqueness of equalizers, the left hand vertical
arrow is an isomorphism.

g. This is an immediate consequence of the Pointwise Adjointness Theorem 13.3.5.

Solutions for Chapter 14

Section 14.1

1. In order that h be a homomorphism of algebras, it is required that the diagram

1 + N

(cid:104)0; s(cid:105)

N(cid:45)

1 + h

(cid:63)
1 + S

h
(cid:63)

S(cid:45)

f

commute. Applied to the element ∗ ∈ 1, this means that h(0) = f (∗) and applied
to h(n) that f (h(n)) = h(succ(n)). This shows the uniqueness of h and since this is
the only condition to be satisﬁed, it shows that h works.

2. The category associated with S has the elements of S as objects and pairs (x, y)
as the unique arrow y −→ x when y ≤ x. Then f takes elements to elements, that
is objects to objects and we deﬁne f on arrows by f (x, y) = (f (x), f (y)) which is
well deﬁned since y ≤ x implies that f (y) ≤ f (x). Since (x, x) is the identity and
f (x, x) = (f (x), f (x)), we see that f preserves identities. Since (x, y) ◦ (y, z) = (x, z)
is the composite, it is immediate that f preserves composition as well.

Solutions for section 14.2

499

Now an object of (f : S) is an x together with an arrow f (x) −→ x. Such an
arrow exists if and only if f (x) ≤ x. So the objects of (f : S) can be identiﬁed as
those elements. If also f (y) ≤ y, then y ≤ x implies that f (y) ≤ f (x) and that

f (y)

y(cid:45)

(cid:63)
f (x)

(cid:63)

x(cid:45)

commutes. Thus (f : S) can be identiﬁed as the set of all x with f (x) ≤ x with the
restricted order. If x0 is initial in (f : S), then f (y) ≤ y implies that x0 ≤ y. But
then f (x0) ≤ x0 implies f (f (x0)) ≤ f (x0) so that y = f (x0) is such an element and
so x0 ≤ f (x0). Thus x0 is ﬁxed and it is clearly the least ﬁxed point.

3. a. Since S (cid:54)= ∅, let s0 be an arbitrary element of S. Deﬁne

(cid:189)

g(t) =

s
s0

if f (s) = t
otherwise

b. Choose g : T −→ S as above. From F (g) ◦ F (f ) = idF (S) it follows easily that

F (f ) is monic.

c. If S = ∅, there is nothing to prove since in that case the inclusions S0 −→ S and
S1 −→ S are isomorphisms. Otherwise let S2 = S0 ∪ S1 unless S0 = S1 = ∅ and in
that case let S2 be any singleton set. Then if i2 : S2 −→ S is inclusion, R(i2) is monic.
Hence from i2 ◦ j0 = i0, i2 ◦ j1 = i1, Ri0(x0) = Ri1(x1) we see that Ri2 ◦ Rj0(x0) =
Ri2 ◦ Rj1(x1) from which Ri2 can be canceled to give Rj0(x0) = Rj1(x1).

Section 14.2

1. In eﬀect we claim that if A∗ is the set of lists of elements of A (including the
empty list ()), then rec(A, B) = A∗ ×B. Let cons : A×A∗ −→ A∗ denote the function
that adjoins an element of A to the head of a list. Then r0(A, B) : B −→ A∗ × B
takes b ∈ B to ((cid:104)(cid:105), b) and r(A, B) : A × A∗ −→ B is just cons × idB. Now let t0 : B
−→ X and t : A×X −→ X be given. In order that f : A∗ ×B −→ X make the diagram
from 14.2.5 commute, it is necessary that f ((cid:104)(cid:105), b) = t0(b) and that f (cons(a, l), b) =
t(a, f (l, b)) for a ∈ A, l ∈ A∗ and b ∈ B. But those conditions deﬁne, by induction
on the length of a word in A∗, a unique function f : A∗ × B −→ X that makes the
necessary diagram commute.

2. From the deﬁnition of recursive in 14.2.5, we see that when A = B = 1, we
get r0(1, 1) : 1 −→ rec(1, 1) and r(1, 1) : rec(1, 1) −→ rec(1, 1) (taking rec(1, 1) as the
product 1 × rec(1, 1)) and the diagram of that section describes exactly the universal
mapping property of a natural numbers object.

500

Solutions for section 14.3

Section 14.3

1. Since T must be a functor, it is a monotone function so that for any x and
y with x ≤ y, T (x) ≤ T (y). Then the existence of the natural transformations
η : id −→ T and µ : T 2 −→ T imply that for any x, x ≤ T (x) and T (T (x)) ≤ T (x).
Since x ≤ T (x), it follows from these inequalities and monotonicity that T (x) ≤
T (T (x)) ≤ T (x), so that T (x) = T (T (x)).

2. We freely use the Godement rules of Section 4.4 together with the identities
satisﬁed by an adjoint pair given in Section 13.2 to compute

µ ◦ T µ = U (cid:178)F ◦ U F η = U ((cid:178)F ◦ F η) = U (idF ) = idU F = idT

µ ◦ ηT = U (cid:178)F ◦ ηU F = (U (cid:178) ◦ ηU )F = idU F = idU F = idT

Now the naturality of (cid:178) implies that for any α : R −→ S,

α ◦ (cid:178)R = (cid:178)S ◦ F U α

Applied when R = F U , S = I (the identity functor) and α = (cid:178), this gives that
(cid:178) ◦ F U (cid:178) = (cid:178) ◦ (cid:178)F U . We then compute

µ ◦ µT = U (cid:178)F ◦ U (cid:178)F U F = U ((cid:178) ◦ (cid:178)F U )F = U ((cid:178) ◦ F U (cid:178))F

= U (cid:178)F ◦ U F U (cid:178)F = µ ◦ T µ

3. If we can identify the η and µ with those determined by the triple, then the
conclusion follows from the preceding exercise. Let us temporarily call the natural
transformations determined by the triple (cid:98)η and (cid:98)µ. Then (cid:98)ηA is deﬁned as the unique
A −→ A∗ such that the extension to a monoid homomorphism F (A) −→ F (A) is the
identity. But η(a) = (a) clearly extends to the identity on F (A) since the extension
takes (a1, . . . , an) to (a1) · · · (an) = (a1, . . . , an) by deﬁnition. Hence (cid:98)η = η.

As for (cid:98)µ = U (cid:178)F , that is the function underlying the unique homomorphism from
F U F (A) to F (A) that is gotten by extending the identity function from U F (A)
to U F (A). This function takes (a1, . . . , an) to itself and the extension to a homo-
morphism takes, for example, the two letter string

((a1, . . . , an), (a(cid:48)

1, . . . , a(cid:48)

n(cid:48))) ∈ F U F (A)

to the product (concatenate)

(a1, . . . , an, a(cid:48)

1, . . . , a(cid:48)

n(cid:48)) ∈ F U (A)

Here we see explicitly that µ and (cid:98)µ agree on two letter strings and it is clear they
agree on strings of arbitrary length.

Solutions for section 14.4

501

Section 14.4

1. Let us write f : A ⇒ B for an arrow in the Kleisli category and f •g for the Kleisli
composition. Then for f : A ⇒ B, we have f • ηA = µB ◦ T f ◦ ηA = µB ◦ ηT B ◦
f = idB ◦ f = f ◦ For g : C ⇒ A, we have ηA • g = µA ◦ T ηA ◦ g = idA ◦ g = g. In
this exercise and many of the later ones we use naturality without comment. Here,
for example, the fact that T f ◦ ηA = ηT B ◦ f is a consequence of the naturality of
η.

2. Using the same notation as in the previous problem, we have, for f : A ⇒ B,
g : B ⇒ C and h : C ⇒ D that (h • g) • f = µD ◦ T (µC ◦ T h ◦ g) ◦ f = µD ◦ T µD ◦
T 2h ◦ T g ◦ f = µD ◦ µT D ◦ T 2h ◦ T g ◦ f = µD ◦ T h ◦ µC ◦ T g ◦ f = h • (g • f ).

3. a. Let us take the last point ﬁrst. Given a monoid structure · and 1 on A, deﬁne
α : A∗ −→ A by α() = 1, α(a) = a and α(a1, a2, · · · , an) = a1 · a2 · · · · · an. Because of
the associativity, it is not necessary to parenthesize that expression. Since α(a) = a,
the identity α ◦ ηA = idA is satisﬁed. As for the identity α ◦ T α = α ◦ µA, let us do
this for a list of length two of A∗; the general case follows by an easy induction. So
2, · · · a(cid:48)
let l = (a1, a2, · · · , an) and l(cid:48) = (a(cid:48)
α ◦ T α(()l(cid:48)) = α(1, a(cid:48)

1, a(cid:48)

n(cid:48)). If n = 0, we have
2 · · · · · a(cid:48)
1 · a(cid:48)
= 1 · a(cid:48)
2 · · · · · a(cid:48)
n(cid:48)
= α(l(cid:48)) = α ◦ µA(()l(cid:48))

1 · a(cid:48)

n(cid:48))

and similarly if n(cid:48) = 0. For n > 0 and n(cid:48) > 0,

α ◦ T α(ll(cid:48)) = α(a1 · a2 · · · · · an, a(cid:48)

= a1 · a2 · · · · · an · a(cid:48)
= α(ll(cid:48)) = α ◦ µA(ll(cid:48))

1 · a(cid:48)

2 · · · · · a(cid:48)
2 · · · · · a(cid:48)
n(cid:48)

1 · a(cid:48)

n(cid:48) )

This shows that each monoid gives an algebra structure. An algebra structure on A
assigns to each list (a1a2 · · · an) ∈ A∗ an element α(a1a2 · · · an) ∈ A. In particular,
there is a multiplication given by a · b = α(ab). Also let 1 denote α(). We must
show that · and 1 constitute a monoid structure and that the associated algebra
structure is the one we started with. It is already evident that if α is the algebra
structure just constructed, then this monoid structure is the original one. We have
α ◦ T α(()(a)) = α(1a) = 1 · a and α ◦ µA(()(a)) = α(a) = a so that 1 · a = a and
similarly a · 1 = a. Next α ◦ T α((a), (b, c)) = a · (b · c) while α ◦ µA((a), (b, c)) =
α(abc). Similarly, using ((a, b), (c)) we can show that (a · b) · c = α(abc) and so ·
is associative. The proof that a · b · c = α(abc) extends by an obvious induction to
show that α(a1, a2, · · · , an) = a1 ·a2 · · · · ·an, which means that the monoid structure
determines uniquely the algebra structure.

b. Let (A, α) and (B, β) be algebra structures with corresponding monoid struc-
tures that we denote ·. Let f : A −→ B. We show that f is a homomorphism of mon-
oids if and only if it is a homomorphism of algebra structures. Suppose f is a homo-
morphism of algebra structures. Then from β ◦ T f () = β() = 1 and f ◦ α() = f (1),
we conclude that f (1) = 1. From β ◦ T f (a, a(cid:48)) = β(f (a)f (a(cid:48))) = f (a) · f (a(cid:48)) and
f ◦ α(a, a(cid:48)) = f (a · a(cid:48)) we see that f is a monoid homomorphism.

If f is a monoid homomorphism, then

β ◦ T f () = β() = 1 = f (1) = f ◦ α()

Solutions for section 14.4

502

and

β ◦ T f (a) = β(f (a)) = f (α(a)) = f ◦ α(a)

If l = (a1, a2, · · · , an), then

β ◦ T f (a1a2 · · · al) = β(f (a1)f (a2) · · · f (an))

= f (a1) · f (a2) · · · · · f (an)
= f (a1 · a2 · · · · · an)
= f ◦ α(a1, a2, · · · , an)

4. The ﬁrst thing to be checked is that (T A, µA) is actually a T-algebra. The
relevant diagrams that have to be checked to be commutative are
T 2A(cid:45)ηT A
T 2A(cid:45)µT A
(cid:64)
=

T 3A

T A

T µA

µA

µA

(cid:64)

(cid:63)
T 2A

(cid:63)
T A(cid:45)

µA

(cid:64)

(cid:64)(cid:82)

(cid:63)
T A

which are two of the three commutative diagrams required for a triple. Next we
have to show that for f : A −→ B, F f : F A −→ F B is an homomorphism in the
category of T-algebras. To do this we must show that the diagram

T 2A

T 2B(cid:45)T 2f

µA

µB

(cid:63)
T A

(cid:63)
T B(cid:45)

T f
commutes. But the commutation of this diagram for all f is exactly what is meant
by the statement that µ is a natural transformation. The fact that F is a functor
is left to the end.

Next we use the result of Theorem 13.3.5 to show that F is left adjoint to U .

To do so we must give an isomorphism

which is natural in B. The function associates to each arrow

Hom(F A, (B, b)) −→ Hom(A, B)

f : (T A, µA) −→ (B, b)

the arrow f ◦ ηA : A −→ B. The naturality of this function follows from that of η. It
must be shown to be an isomorphism. To do this, we deﬁne a function in the other
direction that sends g : A −→ B to b ◦ T g : T A −→ B. First we claim that that arrow
is an arrow of T-algebras. To see that, we must show that the diagram

T 2A

T 2B(cid:45)T 2g

T B(cid:45)T b

µA

(cid:63)
T A

µB

(cid:63)
T B(cid:45)

T g

b
(cid:63)

B(cid:45)

b

Solutions for section 14.4

503

commutes. But the left hand square does by the naturality of µ and the right hand
one does because the commutativity of that square is one of the hypotheses on b.
Next we observe that if f : T A −→ B is an algebra homomorphism, then the square
in the diagram

T A

T 2A(cid:45)T ηA

T B(cid:45)T f

(cid:64)

(cid:64)
=

(cid:64)

µA

b

(cid:64)

(cid:64)(cid:82)

(cid:63)
(cid:63)
T A

(cid:63)

B(cid:45)

f

commutes and the triangle does by one of the identities that deﬁne a triple. Thus
the whole square commutes which shows that one of the composites is the identity.
As for the other, that follows from the commutativity of the diagram

A

(cid:45)g

B

ηA

ηB

(cid:64)

(cid:64)

=

(cid:64)

(cid:63)
T A

(cid:45)

(cid:63)
(cid:63)
T B

T g

(cid:64)
(cid:64)(cid:82)
B(cid:45)

b

whose square commutes by naturality of η and triangle by one of the hypotheses on
b.

Finally we show that F and U are functors, that F

U and that the triple
gotten from the adjoint pair is T. For an object A, U ηA = µA ◦ T ηA = idT A = idU A
so U preserves identities. If f : A ⇒ B and g : B ⇒ C are arrows, then

U g ◦ U f = µC ◦ T g ◦ µB ◦ T f = µC ◦ µT C ◦ T 2g ◦ T f

= µC ◦ T µC ◦ T 2g ◦ T f = µC ◦ T (µC ◦ T g ◦ f )
= µC ◦ T (g • f ) = U (g • f )

so that U preserves composition. Thus U is a functor.

As for F , F idA = ηA ◦ idA = ηA so F preserves identities. If f : A −→ B and

g : B −→ C, then

F g • F f = µC ◦ T F g ◦ F f = µC ◦ T (ηC ◦ g) ◦ ηB ◦ f

= µC ◦ T ηC ◦ T g ◦ ηB ◦ f = ηC ◦ g ◦ f = F (g ◦ f )

and so F is also a functor.

It is evident that T = U F . Also, ηA : A −→ U F A = T A is natural and we let

(cid:178)A = idT A : U F A ⇒ A in K (T). Then

(cid:178)F A • F ηA = µA ◦ T (idT A) ◦ ηT A ◦ ηA = µA ◦ ηT A ◦ ηA

which is the identity of F A. For the other adjointness, we have for B = F A in
K (T),

U (cid:178)F A ◦ ηU F A = µA ◦ T (idA) ◦ ηT A = µA ◦ ηT A = idT A

This completes the proof.

504

Solutions for section 14.5

Section 14.5

1. If A and B are ω-CPOs, let [A −→ B] denote the set of monotone functions from
A to B that preserve joins of countable chains. Make it a poset by the pointwise
ordering, that is f ≤ g if f (a) ≤ g(a) for all a ∈ A. We claim it is an ω-CPO. In
fact, if f0 ≤ f1 ≤ · · · is a countable increasing chain of such functions, then for
each a ∈ A, let f (a) =
fi(a). Let us show that f is countably chain complete (it
will obviously be the join in that case). If a0 ≤ a1 ≤ · · · is a countable increasing
sequence with join a we have a double sequence in which every row and every column
except perhaps the bottom row consists of a countable increasing sequence and its
join.

(cid:87)

f0(a0)
f1(a0)
f2(a0)
...
f (a0)

f0(a1)
f1(a1)
f2(a1)
...
f (a1)
(cid:87)

(cid:87)

f0(a2)
f1(a2)
f2(a2)
...
f (a2)

· · ·
· · ·
· · ·
. . .
· · ·

f0(a)
f1(a)
f2(a)
...
f (a)

For each i, f (ai) =
j fj(a) = f (a) so f (a) is an upper bound for
the bottom row. If b ∈ B were another bound, we would have for each i, fi(a) =
(cid:87)

j fj(ai) ≤

(cid:87)

(cid:87)

j fi(aj) ≤

j f (aj) ≤ b so that f (a) ≤ b. Thus f (a) =

Now we must show that if C is any other ω-CPO,

f (ai).

Hom(C, [A −→ B]) ∼= Hom(C × A, B)

and this isomorphism is natural in B. If f : C × A −→ B is a function, let φ(f ) : C
−→ [A −→ B] be the function deﬁned by φ(f )(c)(a) = f (c, a). So far this is just the
cartesian closed structure on sets. Now we claim that f is countably chain complete
if and only if for all c ∈ C, φ(f )(c) is countably chain complete and φ(f ) is countably
chain complete.

(cid:87)

Suppose f is countably chain complete. This means that if c =

ai
f (ci, ai). This can be specialized
are sups along increasing chains, then f (c, a) =
f (c, ai) so that φ(f )(c) is
to the case that all ci = c to conclude that f (c, a) =
ci is the sup of a countable increasing
countably chain complete. Similarly, if c =
φ(f )(ci).
chain, then the fact that f (c, a) =
This shows one direction. By reversing all these implications, one easily shows that
if φ(f )(c) preserves joins along countable chains and φ(f ) also preserves them, then
f preserves joins in its variables separately. To prove that it preserves them jointly,
ai and consider the double sequence
let c =

f (ci, a) implies that φ(f )(c) =

ci and a =

ci and a =

(cid:87)

(cid:87)

(cid:87)

(cid:87)

(cid:87)

(cid:87)

(cid:87)

(cid:87)

f (c0, a0)
f (c1, a0)
f (c2, a0)
...
f (c, a0)

f (c0, a1)
f (c1, a1)
f (c2, a1)
...
f (c, a1)

f (c0, a2)
f (c1, a2)
f (c2, a2)
...
f (c, a2)

· · ·
· · ·
· · ·
. . .
· · ·

f (c0, a)
f (c1, a)
f (c2, a)
...
f (c, a)

in which all rows and all columns are joins of increasing sequences. Clearly, f (ci, ai) ≤
f (c, a) for all i and if b is an upper bound for the f (ci, ai), then for all j ≥ i,
j(ci, aj) ≤ b. Since this is true for all
f (ci, aj) ≤ f (cj, aj) ≤ b, whence f (ci, a) =
i, it follows that f (c, a) ≤ b. Hence f preserves joins of countable increasing chains.

(cid:87)

Solutions for section 14.5

505

1 ≤ cn

0 ≤ cn

j(n) ≤ cn+1

2 ≤ · · ·. Construct a chain d as follows. Let d0 = c0

j(n+1). This is always possible since cn ≤ cn+1. Let dn+1 = cn+1

2. This is clearly a poset. If c0 ≤ c1 ≤ c2 ≤ · · · is an increasing chain in (cid:98)P , let cn be
the chain cn
0 and having
chosen d0 ≤ d1 ≤ · · · ≤ dn such that di = ci
j(i), choose an integer j(n + 1) > j(n) so
that cn
j(n+1). An
obvious induction shows that j(n) ≥ n and so ci
n ≤ dn for n ≥ i. For a ﬁxed i, the
ﬁnite set of n ≤ i does not matter and so ci ≤ d for all i. Thus d is an upper bound
on the ci. Suppose e = e0 ≤ e1 ≤ e2 ≤ · · · is an upper bound on the ci. Then since
dn = cn
j(n), and cn ≤ e, it follows that dn is less than or equal to some term of e, so
that d ≤ e, whence d = e. Thus (cid:98)P is an ω-CPO. Now suppose that A is an ω-CPO
and f : P −→ A is an order-preserving map. Deﬁne (cid:98)f : (cid:98)P −→ A by (cid:98)f (c) =
f (ci) for
c = c0 ≤ c1 ≤ c2 ≤ · · ·. It is easy to see that this preserves the order and therefore
the equality. Since the join of a constant sequence is itself, this extends f . Finally,
if d is the join of the ci as constructed above, it easily follows from the fact that the
terms of d are a selection of those of the ci that (cid:98)f (d) =
3. Let C be the category of ω-CPOs and functions that preserve joins along count-
able increasing chains and let D : I −→ C be a diagram. Let A be the set that is the
limit of the diagram in sets. Then A comes equipped with projections pI : A −→ DI
for I an object of I . Say that a ≤ a(cid:48) in A if for every object I of I , pI (a) ≤ pI (a(cid:48)).
Then A is a poset and the projections preserve order. If a0 ≤ a1 ≤ a2 ≤ · · · is an in-
creasing chain in A, then for each I, pI (a0) ≤ pI (a1) ≤ pI (a2) ≤ · · · is an countable
increasing chain in DI and has a join aI . If α : I −→ I (cid:48) is an arrow in I , then

(cid:87) (cid:98)f (ci).

(cid:87)

D(α)(aI ) = D(α)

(pI (an))

(cid:195)

(cid:95)

n

(cid:33)

=

(cid:95)

n

D(α)(pI (an)) =

(cid:95)

n

pI (cid:48)(an) = aI (cid:48)

so there is a unique a ∈ A such that pI (a) = aI . Evidently an ≤ a for each integer n.
Also if a(cid:48) ∈ A is another upper bound for the {an} then for each I, pI (an) ≤ pI (a(cid:48))
so that aI = pI (a) ≤ pI (a(cid:48)) and then a ≤ a(cid:48). This shows that A is an ω-CPO and it is
clear that the projections preserve the joins along countable chains. If B is any poset
and {fI } : B −→ D is a natural transformation from the constant diagram to D, let
f : B −→ A be the induced function. Let b0 ≤ b1 ≤ b2 ≤ · · · be an increasing chain in
(cid:87)
n pI (f (bn)).
n fI (bn) so that pI (f (b)) =
B with join b. Then for each I, fI (b) =
n f (bn). The
An argument similar to the above shows that this implies f (b) =
uniqueness of f follows because of the uniqueness of functions into a limit. This
completes the proof for limits.

(cid:87)
(cid:87)

Assuming that the category of posets has colimits, one way to get colimits in the
category of ω-CPOs is to form the colimit in the category of posets and apply the
completion process of the preceding problem. If A is the colimit and (cid:98)A its completion
then any map from A to an ω-CPO extends to a unique map on (cid:98)A that preserves
joins along ω-chains. Putting the two universal mapping conditions together gives
the result.

4. Since a chain is a directed set, one direction is immediate. For the other direction,
let P be an ω-CPO and D ⊆ P be a countable directed set in P . Since D is countable,
we can name the elements of D as d0, d1, d2, . . .. Let c0 = d0 and having chosen
c0 ≤ c1 ≤ c2 ≤ · · · ≤ cn an increasing sequence of elements of D, let cn+1 ∈ D be a
common upper bound of dn+1 and cn. A join of the {cn} is clearly an upper bound
of D.

506

Solutions for section 15.1

Solutions for Chapter 15

Section 15.1

1. Let the pullbacks be

C (cid:48)
0

C0(cid:45)g0

C (cid:48)
1

C1(cid:45)g1

f (cid:48)
0

f0

f (cid:48)
1

f1

(cid:63)
C (cid:48)

(cid:63)

C(cid:45)

g

(cid:63)
C (cid:48)

(cid:63)

C(cid:45)

g

Let u : C0 −→ C1 and v : C1 −→ C0 be the inverse isomorphisms such that f0 ◦ v = f1
and f1 ◦ u = f0. Then f1 ◦ u ◦ g0 = f0 ◦ g0 = g ◦ f (cid:48)
0 so by the universal mapping
property of the right hand pullback, there is a unique u(cid:48) : C (cid:48)
0 −→ C (cid:48)
1 such that
0. Similarly, there is a unique v(cid:48) : C (cid:48)
1 ◦ u(cid:48) = f (cid:48)
g1 ◦ u(cid:48) = f1 ◦ u and f (cid:48)
1 −→ C (cid:48)
0 such that
g0 ◦ v(cid:48) = f0 ◦ v and f (cid:48)
1. Thus f (cid:48)
0 ◦ v(cid:48) = f (cid:48)
2. For f : C0 (cid:41)−→ C, the square

1 belong to the same subobject.

0 and f (cid:48)

C0

C(cid:45)f

idC0

(cid:63)

C0

f

idC
(cid:63)

C(cid:45)

is a pullback. Thus the function induced by the identity of C assigns to each sub-
object of C the subobject itself (or an equivalent one).

3. If S and T are ﬁnite, so is the set of functions between them. In fact if we let
#S denote the number of elements, then #[T −→ S] = #(S)#(T ). For if T = ∅, then
there is exactly one function from T to S no matter what S is. If T (cid:54)= ∅ and S = ∅,
then there are no functions from T to S. If both are nonempty, we suppose by
induction that the conclusion is true for sets with fewer elements than T , let t ∈ T
and T0 = T − {t}. A function from T to S is determined by a function from T0 to
S plus an element of S for t to go to. Thus the number of such functions is

#(S)#(T0)#(S) = #(S)#(T )−1#(S) = #(S)#(T )

which is still ﬁnite. Thus the category of ﬁnite sets is cartesian closed. The two-
element set is also ﬁnite so the category of ﬁnite sets has a subset classiﬁer.
4. It is not quite suﬃcient to point out that when S is inﬁnite, the set 2S of subsets
of S is not countable. The point to be made is that Hom(1, 2S) ∼= Hom(S, 2) (where
here 2 is the set {0, 1}) and the latter set of functions is not countable, while there
is no countable or ﬁnite set T for which Hom(1, T ) is not countable or ﬁnite. Thus
there is no ﬁnite or countable set that has the universal mapping property required
to be the powerset 2S.

Solutions for section 15.2

507

Section 15.2

1. In the category of sets, Ω = 2 so we must verify that

Hom(B, 2A) ∼= Hom(A × B, 2) ∼= Sub(A × B)

If f : B −→ 2A is a function, let φ(f ) : A×B −→ 2 by φ(f )(a, b) = φ(b)(a). If g : A×B
−→ 2 is a function, let ψ(g) = {(a, b) | g(a, b) = 1} ⊆ A × B. If U ⊆ A × B is a subset,
then let
(cid:189)

ρ(U )(b)(a) =

1 if (a, b) ∈ U
if (a, b) /∈ U
0

It is immediate that ρ ◦ ψ ◦ φ = idHom(B,2A) and similarly for the other two serial
composites, from which it is immediate that each of them is invertible, with inverse
the composite of the other two.

2. For x ∈ S, let [x] denote the equivalence class containing it. Then [x] = [y] if and
only if (x, y) ∈ E. Let d 0, d 1 : E −→ S be the two arrows mentioned above and let
d : S −→ S/E denote the arrow x (cid:55)→ [x]. Then for (x, y) ∈ E, d ◦ d 0(x, y) = d(x) =
[x] = [y] = d(y) = d ◦ d 1(x, y) so that d coequalizes d 0 and d 1.

Now suppose that e0, e1 : T −→ S such that d ◦ e0 = d ◦ e1. Then for all x ∈
T , [e0(x)] = [e1(x)]; equivalently (e0(x), e1(x)) ∈ E. Thus we can let f : T −→
E by deﬁning f (x) = (e0(x), e1(x)). Then d 0 ◦ f (x) = d 0(e0(x), e1(x)) = e0(x)
and similarly d 1 ◦ f (x) = e1(x). Finally if g : T −→ E is such that d 0 ◦ g(x) =
d 0(e0(x), e1(x)) = e0(x) and d 1 ◦ g(x) = e1(x), then g(x) = (e0(x), e1(x)) = f (x).

3. a. Suppose that d, e form an equivalence relation. This means that for any
monoid N , the pair

Hom(N, d), Hom(N, e) : Hom(N, E) −→ Hom(N, M )

gives an equivalence relation on the latter. This is another way of saying that

(cid:104)Hom(N, d), Hom(N, e)(cid:105) : Hom(N, E) −→ Hom(N, M ) × Hom(N, M )

is an equivalence relation. Since

Hom(N, M ) × Hom(N, M ) ∼= Hom(N, M × M )

we have that (cid:104)d, e(cid:105) : E −→ M × M is monic. Since the image of a monoid homo-
morphism is a submonoid, the image is a submonoid. By letting N = N, whence
Hom(N, E) and Hom(N, M ) are the underlying sets of E and M respectively, we
conclude that the image of (cid:104)d, e(cid:105) is also an equivalence relation on the set underlying
M . Thus it is a congruence.

Conversely, let d, e : E −→ M have the given property. Then up to isomorphism,
we may suppose that E ⊆ M × M is both a submonoid and an equivalence relation
and that d and e are the inclusion followed by the product projections. Then for
any monoid N , Hom(N, E) consists of those pairs of arrows f, g : N −→ E such that
for all x ∈ N , (f (x), g(x)) ∈ E. Since E is an equivalence relation, it is immediate
that this makes Hom(N, E) into an equivalence relation on Hom(N, M ).

b. Let us suppose that E ⊆ M × M is a submonoid and simultaneously an
equivalence relation. For an x ∈ M , let [x] denote the equivalence class contain-
ing x. If x(cid:48) ∈ [x] and y(cid:48) ∈ [y], then (x, x(cid:48)) ∈ E and (y, y(cid:48)) ∈ E, whence so is

508

Solutions for section 15.2

(x, x(cid:48))(y, y(cid:48)) = (xy, x(cid:48)y(cid:48)). Thus x(cid:48)y(cid:48) ∈ [xy] which means there an unambiguous mul-
tiplication deﬁned on the set M/E of equivalence classes by [x][y] = [xy]. The asso-
ciativity is obvious as is [1][x] = [x][1] = [x]. Thus M/E is a monoid and evidently
the arrow p : M −→ M/E, x (cid:55)→ [x] is a monoid homomorphism. p(x) = p(x(cid:48)) if and
only if x(cid:48) ∈ [x] if and only if (x, x(cid:48)) ∈ E so E is the kernel pair of p.

4. Let f be the coequalizer of the two arrows e0, e1 : E −→ C and let the kernel
pair be d 0, d 1 : K −→ C. Since f ◦ e0 = f ◦ e1, it follows from the universal mapping
property of kernel pairs that there is a unique arrow e : E −→ K such that d 0 ◦ e = e0
and d 1 ◦ e = e1. Now d 0 ◦ f = d 1 ◦ f is one of the deﬁning properties of kernel pairs.
If g : C −→ B is an arrow such that g ◦ d 0 = g ◦ d 1, then g ◦ e0 = g ◦ d 0 ◦ e = g ◦
d 1 ◦ e = g ◦ e1. Since f is the coequalizer of e0 and e1, there is a unique h : D −→ B
such that h ◦ f = g.

5. Let S = {a}, T = {a, b} and f : S −→ T be the inclusion. The kernel pair d 0, d 1
of f is the equality relation on S, that is d 0 = d 1, but f is not the coequalizer. For
any set U with more than one element and any function g : S −→ U there are many
functions h : T −→ U such that h ◦ f = g, since g(b) can be any element of U .

6. Let T be a set, T0 ⊆ T a subset and f : T0 −→ S be an arbitrary function. Deﬁne
(cid:98)f : T −→ S ∪ {∗} by

(cid:110)

(cid:98)f (x) =

f (x)
∗

if x ∈ T0
otherwise

Then T0 = {x ∈ T | (cid:98)f (x) ∈ S}, which is another way of saying that

T0

S(cid:45)f

(cid:63)
T

(cid:45)
(cid:98)f

(cid:63)
S ∪ {∗}

is a pullback. If g is a function with the same property, then g(x) ∈ S if and only if
(cid:98)f (x) is, which means that g(x) = ∗ if and only if f (x) = ∗. Also, if g(x) (cid:54)= ∗, then
x ∈ T0 so that g(x) = f (x) = (cid:98)f (x). Thus g = (cid:98)f in all cases.
7. Since each object has a unique arrow to 1, there is a one to one correspondence
between subobjects of an object A and partial arrows of A to 1. But partial arrows
of A to 1 are in one to one correspondence with arrows A −→ (cid:101)1. Thus Hom(A, (cid:101)1) ∼=
Sub(A) which is the deﬁning property of Ω.

Section 15.4
1. We are thinking of C = 0 −→−→ 1 as a category and 0 and 1 as two objects. The
category of graphs is the category of contravariant functors C −→ Set. In particular,
the objects 0 and 1 represent functors and the question is which ones. Let us denote
the two nonidentity arrows of C by s and t (mnemonic for ‘source’ and ‘target’). A
functor F : C −→ Set determines and is determined by the two sets F (1) and F (0)
and the two arrows F (s) : F (1) −→ F (0) and f (t) : F (1) −→ F (0). In the case that

Solutions for section 15.5

509

F = Hom(−, 0), the two sets are Hom(0, 0) and Hom(1, 0) which are a one-element
set and the empty set, respectively, and the functions are the unique functions that
exists in that case. Thus the contravariant functor represented by 0 is the graph 1
which we have also called No.

For take the functor represented by 1, the two sets are Hom(1, 1) = {id1} and
Hom(0, 1) = {s, t}. The two arrows take the element of Hom(1, 1) to s and t re-
spectively. The graph 2 that we have also called No has just one arrow and two
nodes which are the source and target of the arrow, respectively, and so is the graph
represented by 1.

2. There are two ways of dealing with this question and similar ones. We already
have an explicit description of the subobject classiﬁer in this category and we could
simply examine the set of nodes and set of arrows and see that their subfunctors
have the desired structure. However, there is an easier way, once we know there is a
subobject classiﬁer. For the set of subobjects of the graph No is Hom(No, Ω) which,
in turn, is isomorphic by the preceding problem, to the set of nodes of Ω. Similarly,
the set of subobjects of the graph Ar is Hom(Ar, Ω), which is the set of arrows of
Ω.

3. Let NT(F, G) denote the set of natural transformations between functors F and
G. The Yoneda lemma implies that if [M −→ N ] = F , then

F (X) ∼= NT(Hom(−, X), F ) ∼= NT(Hom(−, X), [M −→ N ])

∼= NT(Hom(−, X) × M, N )

4. We have that

Sub(Hom(−, X)) ∼= NT(Hom(−, X), Ω) ∼= Ω(X)

the latter by the Yoneda Lemma.

Section 15.5

1. a. Let C = {c ∈ H | a ∧ c ≤ b}. Then a ⇒ b =
(cid:95)

(cid:95)

a ∧ (a ⇒ b) = a ∧

c =

(cid:87)

c∈C c. Then

(a ∧ c) ≤ b

c∈C

c∈C

since a join of elements less than b is also less than b. Therefore, if c ≤ a ⇒ b then
a ∧ c ≤ b. On the other hand, if a ∧ c ≤ b, then c ∈ C so that c ≤ a ⇒ b.

b. The fact that a ≤ b ∧ c if and only if a ≤ b and a ≤ c means that when the
Heyting algebra is considered as a category, Hom(a, b ∧ c) = Hom(a, b) × Hom(a, c).
This means that b ∧ c is the categorical product of b and c. But then a ∧ c ≤ b if
and only if c ≤ a ⇒ b means that Hom(a × c, b) = Hom(c, a ⇒ b), which means that
a ⇒ b is the internal hom.

510

Solutions for section 16.2

Solutions for Chapter 16

Section 16.2

1. Suppose f : A(cid:48) −→ A is given. In the diagram below, the upper and lower trape-
zoids commute by the naturality of the isomorphism, the left and right hand trape-
zoids commute from the deﬁnitions of B −◦ (f −◦ C) and (f ⊗ B) −◦ C, resp. and
the inner square commutes by deﬁnition of f −◦ C. Therefore the outer square com-
mutes.

Hom(D, B −◦ (A −◦ C))

(cid:45)

Hom(D, (A ⊗ B) −◦ C)

(cid:64)
∼=
(cid:64)

(cid:64)

(cid:64)(cid:82)

(cid:161)
∼=
(cid:161)

(cid:161)

(cid:161)(cid:170)

Hom(B ⊗ D, A −◦ C)

(cid:45)

Hom(A ⊗ B ⊗ D, C)

(cid:63)
Hom(B ⊗ D, A(cid:48) −◦ C)

(cid:63)
Hom(A(cid:48) ⊗ B ⊗ D, C)

(cid:45)

(cid:161)(cid:181)

(cid:161)

(cid:64)(cid:73)

(cid:64)

∼=
(cid:161)
(cid:161)

(cid:63)
Hom(D, B −◦ (A(cid:48) −◦ C))

∼=
(cid:64)
(cid:64)

(cid:63)
Hom(D, (A(cid:48) ⊗ B) −◦ C)

(cid:45)

According to the Yoneda Lemma, it follows that

B −◦ (A −◦ C)

(cid:45)∼=

(A ⊗ B) −◦ C

B −◦ (f −◦ C)

(f ⊗ B) −◦ C

(cid:63)
B −◦ (A(cid:48) −◦ C)

(cid:63)

(A(cid:48) ⊗ B) −◦ C

(cid:45)

∼=

commutes. This is just the internalized version (that is, with Hom sets replaced by
−◦) of the main diagram used to prove the naturality in the preceding exercise. By
replacing Hom sets everywhere in that argument with these ‘internal hom objects’,
the above proof can be adapted to give the solution to this exercise.

2. We begin by showing that M is the unit. We must give, for each M -action S an
isomorphism l = lS : M ⊗M S −→ S. Since S ⊗ M is deﬁned only up to isomorphism
as a coequalizer, one way of doing this is to show how S itself can be made into the
relevant coequalizer, that is that there is a coequalizer diagram of the form

M × M × S

d0
−−→−−→
d1

M × S

d
−−→ S

where d0(m, n, s) = (mn, s) and d1(m, n, s) = (m, ns). Deﬁne d(m, s) = ms. The
fact that d ◦ d0 = d ◦ d1 is just condition A–2 of 3.3.2.1. Now suppose that f : M × S

Solutions for section 16.2

511

−→ T is an equivariant map of M -actions such that f ◦ d0 = f ◦ d1. Deﬁne g : S
−→ T by g(s) = f (1, s). Then (g ◦ d)(m, s) = g(ms) = f (1, ms) = (f ◦ d1)(1, m, s) =
(f ◦ d0)(1, m, s) = f (m, s) so that f = g ◦ d. If h : S −→ T is another map such that
h ◦ d = f , then for all s ∈ S, h(s) = (h ◦ d)(1, s) = f (1, s) = g(s). This shows that
S is the coequalizer, so that M ⊗ S can be taken to be S.

To show associativity, suppose that R, S and T are M -actions. Deﬁne a =
a(R, S, T ) : R ⊗ (S ⊗ T ) −→ (R ⊗ S) ⊗ T by a(r ⊗ (s ⊗ t)) = (r ⊗ s) ⊗ t. We have
that

a(mr ⊗ (s ⊗ t)) = (mr ⊗ s) ⊗ t = (r ⊗ ms) ⊗ t

= a(r ⊗ (ms ⊗ t)) = a(r ⊗ m(s ⊗ t))

so that a is well deﬁned on the tensor product. It is just as easy to show it is M -
equivariant and the similarly constructed inverse map shows it is an isomorphism.
We similarly deﬁne c = c(S, T ) : S ⊗ T −→ T ⊗ S by c(s ⊗ t) = t ⊗ s which can be
similarly shown to be well-deﬁned and equivariant.

Now suppose f : R ⊗ S −→ T is an equivariant map. Deﬁne φ(f ) : S −→ R −◦ T
by φ(f )(s) ∈ S −◦ T is the map for which φ(f )(s)(r) = f (r, s). We have to show for
each f and s, that φ(f )(s) is equivariant; for each f , that φ(f ) is equivariant and,
ﬁnally, that φ is equivariant. Each of the three is a diﬀerent assertion. For the ﬁrst,
we have that

φ(f )(s)(mr) = f (mr ⊗ s) = f (m(r ⊗ s)) = mf (r, s) = mφ(f )(s)(r)

The second follows from

φ(f )(ms)(r) = f (r ⊗ ms) = f (m(r ⊗ s)) = mf (r ⊗ s)

= mφ(f )(s)(r) = (mφ(f )(s))(r)

The second computation looks quite similar to the ﬁrst, but really is diﬀerent since
it depends on the fact that the action of M on a map g : R −→ T is by (mg)(r) =
mg(r). As for the third, we have that

φ(mf )(s)(r) = (mf )(r, s) = mf (r, s) = mφ(f )(s)(r)

= (mφ(f )(s))(r) = (mφ(f ))(s)(r)

so that φ(mf ) = mφ(f ) where we have twice used the deﬁnition of the action
of M on a homomorphism. To go the other way, given an equivariant map g : S
−→ R −◦ T , deﬁne ψ(g) : R ⊗ S −→ T by ψ(g)(r, s) = g(s)(r). The crucial fact, that
ψ(g)(mr, s) = ψ(g)(r, ms), is shown by

ψ(g)(mr, s) = g(s)(mr) = m(g(s)(r))

= (mg(s))(r) = g(ms)(r) = ψ(g)(r, ms)

The rest, such as that ψ is equivariant, is similar. It is easily seen that ψ = φ−1.

3. a. If F is a functor, then let F (A, −) be deﬁned on arrows g : B −→ B(cid:48) by
F (A, g) = F (idA, g) and F (−, B) similarly deﬁned on arrows f : A −→ A(cid:48) by F (f, B) =

512

Solutions for section 16.2

F (f, idB). The commutation follows from the equations (f, g) = (f, idB(cid:48)) ◦ (idA, g) =
(idA(cid:48) , g) ◦ (f, idB).

Conversely, if we have the condition satisﬁed, deﬁne

F (f, g) = F (A, g) ◦ F (f, B) = F (f, b) ◦ F (A, g)

Since id(A,B) = (idA, idB), we have

F (id(A,B)) = F (idA, idB) = F (idA, B) ◦ F (A, idB)

= idF (A,B) ◦ idF (A,B) = idF (A,B)

If (f, g) : (A, B) −→ (C, D) and (f (cid:48), g(cid:48)) : (A(cid:48), B(cid:48)) −→ (A(cid:48)(cid:48), B(cid:48)(cid:48)) then

F (f (cid:48), g(cid:48)) ◦ F (f, g) = F (f (cid:48), B(cid:48)(cid:48)) ◦ F (A(cid:48), g(cid:48)) ◦ F (A(cid:48), g) ◦ F (f, B)

= F (f (cid:48), B(cid:48)(cid:48)) ◦ F (A(cid:48), g(cid:48) ◦ g) ◦ F (f, B)

= F (f (cid:48), B(cid:48)(cid:48)) ◦ F (f, B(cid:48)(cid:48)) ◦ F (A, g ◦ g(cid:48))

= F (f (cid:48) ◦ f, B(cid:48)(cid:48)) ◦ F (A, g ◦ g(cid:48)) = F (f (cid:48) ◦ f, g(cid:48) ◦ g)

b. The deﬁnition of naturality of F (f, −) is that for all g : B −→ B(cid:48), the square

F (A, B)

F (A, g)

(cid:45)

F (A, B(cid:48))

F (f, B)

F (f, B(cid:48))

(cid:63)
F (A(cid:48), B)

(cid:63)
F (A(cid:48), B(cid:48))

(cid:45)

F (A(cid:48), g)

commutes, which is exactly the third condition and also exactly the naturality of
F (−, g).

c. Naturality of α means that for each arrow (f, g) : (A, B) −→ (A(cid:48), B(cid:48)) the

diagram

F (A, B)

F (f, g)

(cid:45)

F (A(cid:48), B(cid:48))

α(A, B)

α(A(cid:48), B(cid:48))

(cid:63)
G(A, B)

(cid:63)
G(A(cid:48), B(cid:48))

(cid:45)

G(f, g)

Specializing to the case that f : A −→ A is the identity, we see that if α is natural,
then so is α(A, −) and similarly for α(−, B). Conversely, suppose that all α(A, −)
and α(−, B) are natural. First we observe that (f, g) = (id, g) ◦ (f, id) (this is the

crucial observation, actually) and hence F (f, g) = F (id, g) ◦ F (f, id) and analo-
gously for G. This gives us the following commutative diagram

Solutions for section 16.2

513

F (f, g)

F (A, B)

F (f, B)

(cid:45)

F (A(cid:48), B)

F (A, g)

(cid:85)
(cid:45)

F (A(cid:48), B(cid:48))

α(A, B)

(cid:63)

G(A, B)

α(A(cid:48), B)

α(A(cid:48), B(cid:48))

(cid:63)
G(A(cid:48), B)

(cid:45)

G(f, B)

(cid:63)
G(A(cid:48), B(cid:48))

G(A(cid:48), g)

(cid:45)
(cid:184)

G(f, g)

Since the two squares and the two triangles commute, so does the outer diagram,
which is just the naturality of α.

d. Suppose we have f : A(cid:48) −→ A. Since the bottom map in the diagram be-
low is an isomorphism, there is, for each B and C a unique arrow α(B, C) :
Hom(B, A −◦ C) −→ Hom(B, A(cid:48) −◦ C) such that

Hom(B, A −◦ C)

(cid:45)∼=

Hom(A ⊗ B, C)

α(B, C)

Hom(f ⊗ B, C)

(cid:63)
Hom(B, A(cid:48) −◦ C)

(cid:63)
Hom(A(cid:48) ⊗ B, C)

(cid:45)

∼=

commutes. I claim that this is natural in B. In fact, if B(cid:48) −→ B is a map, we have
a diagram

Hom(B, A −◦ C)

(cid:45)

Hom(B(cid:48), A −◦ C)

(cid:64)
∼=
(cid:64)

(cid:64)

(cid:64)(cid:82)

Hom(A ⊗ B, C)

(cid:161)
∼=
(cid:161)

(cid:161)

(cid:161)(cid:170)

(cid:45)

Hom(A ⊗ B(cid:48), C)

(cid:63)
Hom(A(cid:48) ⊗ B, C)

(cid:63)
Hom(A(cid:48) ⊗ B(cid:48), C)

(cid:45)

(cid:161)(cid:181)

(cid:161)

∼=
(cid:161)
(cid:161)

(cid:63)
Hom(B, A(cid:48) −◦ C)

(cid:64)(cid:73)

(cid:64)

∼=
(cid:64)
(cid:64)

(cid:63)
Hom(B(cid:48), A(cid:48) −◦ C)

(cid:45)

The left and right hand trapezoids commute by deﬁnition of α; the top and bottom
ones because of the naturality of isomorphisms in the adjunction. The middle square
commutes because ⊗ is a functor. It follows from a simple diagram chase that the

514

Solutions for section 16.2

outer square commutes, which is just naturality of α(B, C) with respect to B. Thus
we have, for each C, a natural transformation Hom(−, A −◦ C) −→ Hom(−, A(cid:48) ⊗ C).
The Yoneda lemma implies that any such natural transformation is induced by
a unique map we call f −◦ C : A −◦ C −→ A(cid:48) −◦ C. If f is the identity, then the
identity map of A −◦ C has all the properties required of f −◦ C. It then follows
from uniqueness that id −◦ C is the identity. If f (cid:48) : A(cid:48)(cid:48) −→ A(cid:48) is a morphism, then one
easily sees that (f −◦ C) ◦ (f (cid:48) −◦ C) has all the properties required of (f ◦ f (cid:48)) −◦ C
and the uniqueness implies they are equal. Thus the object function A (cid:55)→ A −◦ C
extends to a functor.

If h : C −→ C (cid:48) is given, then the same argument with appropriate changes gives
maps A −◦ h : A −◦ C −→ A −◦ C (cid:48) for each A. For example, for each A and B we
have a unique function γ(A, B) : Hom(B, A −◦ C) −→ Hom(B, A −◦ C (cid:48)) for which
(cid:45)∼=

Hom(B, A −◦ C)

Hom(A ⊗ B, C)

γ(A, B)

Hom(A ⊗ B, h)

(cid:63)
Hom(B, A −◦ C (cid:48))

(cid:63)
Hom(A ⊗ B, C (cid:48))

(cid:45)

∼=

commutes. This is natural in B and thus there is a unique map A −◦ h : A −◦ C
−→ A −◦ C (cid:48) as above. To complete the argument, we must show that for f : A(cid:48) −→ A
and h : C −→ C (cid:48), (A(cid:48) −◦ h) ◦ (f ◦ C) = (f ◦ C (cid:48)) ◦ (A −◦ h). This follows from the
commutativity of

Hom(B, A −◦ C)

(cid:45)

Hom(B, A(cid:48) −◦ C)

(cid:64)
∼=
(cid:64)

(cid:64)

(cid:64)(cid:82)

Hom(A ⊗ B, C)

(cid:161)
∼=
(cid:161)

(cid:161)

(cid:161)(cid:170)

(cid:45)

Hom(A(cid:48) ⊗ B, C)

(cid:63)
Hom(A ⊗ B, C (cid:48))

(cid:63)
Hom(A(cid:48) ⊗ B, C (cid:48))

(cid:45)

(cid:161)(cid:181)

(cid:161)

∼=
(cid:161)
(cid:161)

(cid:63)
Hom(B, A −◦ C (cid:48))

(cid:64)(cid:73)

(cid:64)

∼=
(cid:64)
(cid:64)

(cid:63)
Hom(B, A(cid:48) −◦ C (cid:48))

(cid:45)

The four trapezoids commute from the deﬁnitions of f −◦ − and − −◦ h, while the
inner square does because ⊗ is a functor and hence the outer square does too. One
easily sees that for three variables it is suﬃcient that all the restrictions to two
variables be functorial, since all the necessary commutations can be performed by
permuting two variables at a time.

Solutions for section 16.3

515

Section 16.3

1. a. Since there is are only ﬁnitely many elements, there is a sup of all them,
clearly the greatest element. Given any two elements x and y the set of elements z
such that z ≤ x and z ≤ y is ﬁnite and therefore has a sup, which is evidently the
inf of x and y.

b. This is actually an instance of the fact that right adjoints preserve limits
(Theorem 13.3.7), since if L and M are treated as categories, f and g are functors
and f is left adjoint to g, since from the deﬁnition of g, x ≤ g(y) if and only
if f (x) ≤ y. In particular, f (x) ≤ y and f (x) ≤ y(cid:48) if and only if f (x) ≤ y ∧ y(cid:48).
Thus x ≤ g(y) and x ≤ g(y(cid:48)) if an only if x ≤ g(y ∧ y(cid:48)) from which it follows that
x ≤ g(y)∧g(y(cid:48)) if and only if x ≤ g(y ∧y(cid:48)) which implies that g(y ∧y(cid:48)) = g(y)∧g(y(cid:48)).
c. The previous part shows that when f : L −→ M is sup preserving, then so
∗∗

is f ∗ = g : M ∗ −→ L∗. The uniqueness of adjoints implies that f
is another left adjoint to f (note that although g : M −→ L is a right adjoint to
f , g : M op −→ Lop is left adjoint.) Thus ∗ looks like a duality. We must also show
that L −◦ M ∼= M ∗ −◦ L∗. But in fact the correspondence f (cid:55)→ f ∗ is a one-one
correspondence between the two hom sets. If f ≤ g : L −→ M are sup preserving,
then I claim that f ∗ ≤ g∗ : M ∗ −→ L∗, which is equivalent to the statement that
g∗ ≤ f ∗ : M −→ L. In fact, this is a general fact about adjoints. If F , G : A −→ B
are functors with right adjoints F ∗, G∗, resp., then any natural transformation α : F
−→ G induces a natural transformation G∗ −→ F ∗ by the composite G∗ −→ G∗F F ∗
−→ G∗GF ∗ −→ F ∗, where the ﬁrst and third map are induced by the adjunctions
and the middle one by α. Between posets, there is one natural transformation f
−→ g if and only if f ≤ g and none otherwise. Thus f ≤ g if and only if g∗ ≤ f ∗,
just what is required for this to be a duality in the closed monoidal category.

= f since f

∗∗

Bibliography

At the end of each entry, the pages on which that entry is cited are listed in paren-
theses.

Ad´amek, J. and J. Rosiˇcky (1994). Locally Presentable and Accessible Categories.

Cambridge University Press.

(xv, 102, 139, 219, 299, 300, 312)

Arbib, M. and E. Manes (1975). Arrows, Structures and Functors: The Categorical

Imperative. Academic Press.
Arbib, M. and E. Manes (1980).

(372)

‘Machines in a category’. Journal of Pure and

Applied Algebra, volume 19, pages 9–20.

(372)

Asperti, A. and G. Longo (1991). Categories, Types and Structures. The MIT

Press.

(xv, 417, 422)

Asperti, A. and S. Martini (1992).

mation and Computation, volume 99, pages 1–79.

‘Categorical models of polymorphism’. Infor-
(332)

Backhouse, R., M. Bijsterveld, R. van Geldrop, and J. van der Woude (1995). ‘Cat-

egorical ﬁxed point calculus’. In Pitt et al. [1995], pages 159–179.

(215)

Backus, J. (1981).

‘The algebra of functional programs: Function level reasoning,
linear equations, and extended deﬁnitions’. In Formalization of Programming
Concepts, J. Diaz and I. Ramos, editors, volume 107 of Lecture Notes in Com-
(20, 34, 215)
puter Science. Springer-Verlag.

Backus, J. (1981).

‘Is computer science based on the wrong fundamental concept
of program?’. In Algorithmic Languages, J. W. deBakker and J. C. van Vliet,
editors. North-Holland.

(20)

Baez, J. C. (1997). ‘An introduction to n-categories’. In Moggi and Rosolini [1997],

pages 1–33.

(140)

Bagchi, A. and C. Wells (1997).

‘Graph-based logic and sketches I: The general
framework’. Available by web browser from http://www.cwru.edu/artsci/
math/wells/pub/wellspub.html.

(311, 312)

Bagchi, A. and C. Wells (1997).

‘Graph-based logic and sketches II: Equational
deduction’. Available by web browser from http://www.cwru.edu/artsci/
(249)
math/wells/pub/wellspub.html.

Barendregt, H. (1984). The Lambda Calculus – its Syntax and Semantics. North-

Holland.

(29, 208)

Barr, M. (1971). ‘Exact categories’. In Exact Categories and Categories of Sheaves,

volume 236 of Lecture Notes in Mathematics. Springer-Verlag.

(367)

Barr, M. (1979). *-Autonomous Categories, volume 752 of Lecture Notes in Math-

ematics. Springer-Verlag.

(422, 519)

Barr, M. (1986). ‘Fuzzy sets and topos theory’. Canadian Math. Bull., volume 24,

pages 501–508.

(400)

Barr, M. (1986). ‘Models of sketches’. Cahiers de Topologie et G´eom´etrie Diff´eren-

tielle Cat´egorique, volume 27, pages 93–107.

(240, 244, 304)

517

518

Bibliography

Barr, M. (1989). ‘Models of Horn theories’. Contemporary Mathematics, volume 92,

pages 1–7.

(299)

Barr, M. (1990). ‘Fixed points in cartesian closed categories’. Theoretical Computer

Science, volume 70, pages 65–72.

(218)

Barr, M. (1991).

‘∗-autonomous categories and linear logic’. Mathematical Struc-

tures in Computer Science, volume 1, pages 159–178.

(422)

Barr, M. (1995). ‘Non-symmetric *-autonomous categories’. Theoretical Computer

Science, volume 139, pages 115–130.

(422, 424)

Barr, M. (1996). ‘∗-autonomous categories, revisited’. Journal of Pure and Applied

Algebra, volume 111, pages 1–20.

(422)

Barr, M. (1996).

‘The Chu construction’. Theory and Applications of Categories,

volume 2, pages 17–35.

(424)

Barr, M. (1996). ‘Separability of tensor in Chu categories of vector spaces’. Math-

ematical Structures in Computer Science, volume 6, pages 213–217.

(429)

Barr, M., C. McLarty, and C. Wells (1985). ‘Variable set theory’. Technical report,

McGill University.

(77, 400)

Barr, M. and C. Wells (1985). Toposes, Triples and Theories, volume 278 of Grund-
lehren der mathematischen Wissenschaften. Springer-Verlag, New York. A list
of corrections and additions is maintained in [Barr and Wells, 1993].
(xv, 139,
237, 279, 303, 307, 309, 311, 312, 347, 357, 358, 375, 384, 386, 387, 388, 389,
394, 396, 518)

Barr, M. and C. Wells (1992). ‘On the limitations of sketches’. Canadian Mathe-

matical Bulletin, volume 35, pages 287–294.

(312)

Barr, M. and C. Wells (1993). ‘Corrections to Toposes, Triples and Theories’. Avail-
able by anonymous FTP from triples.math.mcgill.ca in directory pub/
barr and by web browser from http://www.cwru.edu/artsci/math/wells/
pub/wellspub.html. Corrections and additions to [Barr and Wells, 1985].
(518)

Bartha, M. (1992). ‘An algebraic model of synchronous systems’. Information and

Computation, volume 97, pages 1–31.

(417)

Bastiani, A. and C. Ehresmann (1972). ‘Categories of sketched structures’. Cahiers
de Topologie et G´eom´etrie Diff´erentielle, volume 13, pages 104–213.
(219,
307, 311)

Bell, J. L. (1988). Toposes and Local Set Theories: An Introduction. Oxford Logic

Guides. Oxford University Press.

(xv, 187, 384)

Bergman, C. and J. Berman (1998). ‘Algorithms for categorical equivalence’. Math-

ematical Structures in Computer Science, volume 8, pages 1–16.

(87)

Bird, R. S. (1986). ‘An introduction to the theory of lists’. In Logic of Programming
and Calculi of Discrete Designs, M. Broy, editor, pages 5–42. Springer-Verlag.
(112)

Bloom, S. and E. Wagner (1985).

‘Many-sorted theories and their algebras with
some applications to data types’. In Algebraic Methods in Semantics, M. Nivat
and J. C. Reynolds, editors. Cambridge University Press.

(250)

Boileau, A. and A. Joyal (1981). ‘La logique des topos’. Symbolic Logic, volume 46,

pages 6–16.

(384)

Borceux, F. (1994). Handbook of Categorical Algebra I, II and III. Cambridge

University Press.

(xv)

Bibliography

519

Carboni, A., P. Freyd, and A. Scedrov (1988).

‘A categorical approach to realiz-
ability and polymorphic types’. In Mathematical Foundations of Programming
Language Semantics, M. Main, A. Melton, M. Mislove, and D. Schmidt, edi-
tors, volume 298 of Lecture Notes in Computer Science, pages 23–42. Springer-
Verlag.

(408)

Cartmell, J. (1986). ‘Generalized algebraic theories and contextual categories’. An-

nals Pure Applied Logic, volume 32, pages 209–243.

(300)

Chen, H. G. and J. R. B. Cockett (1989).

‘Categorical combinators’. Technical

report, University of Calgary.

(347)

Chu, P.-H. (1978). ‘Constructing *-autonomous categories’. Master’s thesis, McGill

University.
Chu, P.-H. (1979).
(424)

1979].

(424)

‘Constructing *-autonomous categories’. Appendix to [Barr,

Cockett, J. R. B. (1989). ‘On the decidability of objects in a locos’. In Categories in
Computer Science and Logic, J. W. Gray and A. Scedrov, editors, volume 92
(368, 371)
of Contemporary Mathematics. American Mathematical Society.
‘List-arithmetic distributive categories: Locoi’. Journal

Cockett, J. R. B. (1990).

of Pure and Applied Algebra, volume 66, pages 1–29.

(368, 369)

Cockett, J. R. B. (1993).

‘Introduction to distributive categories’. Mathematical

Structures in Computer Science, volume 3, pages 277–307.

(188, 189)

Cockett, J. R. B. and D. Spencer (1992). ‘Strong categorical datatypes i’. In Cat-
egory Theory 1991, R. Seely, editor. American Mathematical Society.
(330,
376)

Coppey, L. and C. Lair (1984).

‘Le¸cons de th´eorie des esquisses’. Diagrammes,

volume 12.

(219)

Coppey, L. and C. Lair (1988).
grammes, volume 19.

(219)

‘Le¸cons de th´eorie des esquisses, partie II’. Dia-

Coquand, T. (1988). ‘Categories of embeddings’. In Proceedings of the Third Annual
Symposium on Logic in Computer Science, Edinburgh, 1988, pages 256–263.
Computer Society Press and IEEE.

(332)

Coquand, T. and G. Huet (1988). ‘The calculus of constructions’. Information and

Computation, volume 76, pages 95–120.

(332)

‘A categorical model for logic programs:
Corradini, A. and A. Asperti (1993).
In Semantics: Foundations and Applications
Indexed monoidal categories’.
(Beekbergen, 1992), volume 666 of Lecture Notes in Computer Science, pages
110–137. Springer-Verlag.

(417)

Corradini, A. and F. Gadducci (1997). ‘A 2-categorical presentation of term graph

rewriting’. In Moggi and Rosolini [1997], pages 87–105.

(141)

Coste, M. (1976). ‘Une approche logique des th´eories d´eﬁnissables par limites pro-

jectives ﬁnies’. In S´eminaire B´enabou. Universit´e Paris-Nord.

(300)

Cousineau, G., P.-L. Curien, and M. Mauny (1985). ‘The categorical abstract ma-
In Functional Programming Languages and Computer Architecture,

chine’.
volume 201 of Lecture Notes in Computer Science. Springer-Verlag.

(195)

Crole, R. L. (1994). Categories for Types. Cambridge University Press.
Curien, P.-L. (1986). Categorical Combinators, Sequential Algorithms and Func-

(xv)

tional Programming. Wiley.

(195)

Davey, B. A. and H. A. Priestley (1990). Introduction to Lattices and Order. Cam-

bridge University Press.

(180)

520

Bibliography

Devlin, K. (1993). The Joy of Sets: Fundamentals of Contemporary Set Theory,
(2)
Second Edition. Undergraduate Texts in Mathematics. Springer-Verlag.
‘Cat´egories localement multipr´esentables’. Arch. Math., vol-

Diers, Y. (1980).

ume 34, pages 344–356.

(257, 347)

Diers, Y. (1980).

‘Quelques constructions de cat´egories localement multipr´esenta-

bles’. Ann. Sci. Math. Qu´ebec, volume 4, pages 79–101.

(257, 347)

Duval, D. and J.-C. Reynaud (1994). ‘Sketches and computation (1)’. Mathematical

Structures in Computer Science, volume 4.

(260)

Duval, D. and J.-C. Reynaud (1994). ‘Sketches and computation (2)’. Mathematical

Structures in Computer Science, volume 4.

(260)

Dybjer, P. (1986). ‘Category theory and programming language semantics: an over-
view’. In Category Theory and Computer Programming, D. Pitt, S. Abramsky,
A. Poign´e, and D. Rydeheard, editors, volume 240 of Lecture Notes in Com-
puter Science, pages 165–181. Springer-Verlag.

(201)

Dybkjaer, H. and A. Melton (1993).

‘Comparing Hagino’s categorical program-
ming language and typed lambda-calculi’. Theoretical Computer Science, vol-
ume 111, pages 145–189.

(195)

Edalat, A. and M. B. Smyth (1993). ‘I-categories as a framework for solving domain
(147)
‘Esquisses et types des structures alg´ebriques’. Bul. Inst.

equations’. Theoretical Computer Science, volume 115, pages 77–106.

Ehresmann, C. (1968).

Polit. Ia¸si, volume XIV.

(307, 311)

Ehrhard, T. (1988).

‘A categorical semantics of constructions’. In Proceedings of
the Third Annual Symposium on Logic in Computer Science, Edinburgh, 1988.
Computer Society Press and IEEE.

(332)

Ehrich, H. (1986).

‘Key extensions of abstract data types, ﬁnal algebras, and
database semantics’. In Category Theory and Computer Programming, D. Pitt,
S. Abramsky, A. Poign´e, and D. Rydeheard, editors, volume 240 of Lecture
Notes in Computer Science. Springer-Verlag.

(250)

Ehrig, H., H. Herrlich, H. J. Kreowski, and G. Preuss, editors (1988). Categorical
Methods in Computer Science, volume 393 of Lecture Notes in Computer Sci-
ence. Springer-Verlag.

(xv)

Ehrig, H., H. J. Kreowski, J. Thatcher, E. Wagner, and J. Wright (1984). ‘Parameter
passing in algebraic speciﬁcation languages’. Theoretical Computer Science,
volume 28, pages 45–81.

(319)

Ehrig, H. and B. Mahr (1985). Fundamentals of Algebraic Speciﬁcations I. Springer-

Verlag.

(249)

Eilenberg, S. (1976). Automata, Languages and Machines, Vol. B. Academic Press.

(76, 344)

Eilenberg, S. and J. C. Moore (1965).
Math., volume 9, pages 381–398.

‘Adjoint functors and triples’. Illinois J.
(374)

Fokkinga, M. M. (1992). ‘Calculate categorically!’. Formal Aspects of Computing,

volume 4.
(xv)
Fourman, M. (1977).

‘The logic of topoi’.

In Handbook of Mathematical Logic,

J. Barwise, editor. North-Holland.

(384)

Fourman, M., P. Johnstone, and A. Pitts (1992). Applications of Categories in
Computer Science, volume 177 of London Mathematical Society Lecture Notes
Series. Cambridge University Press.

(xv)

Bibliography

521

Fourman, M. and S. Vickers (1986).

‘Theories as categories’. In Category Theory
and Computer Programming, D. Pitt, S. Abramsky, A. Poign´e, and D. Ryde-
heard, editors, volume 240 of Lecture Notes in Computer Science, pages 434–
448. Springer-Verlag.

(384)

Freyd, P. and A. Scedrov (1990). Categories, Allegories, volume 39 of North-Holland

Mathematical Library. North-Holland.

(xv, 87, 358, 384)

Gabriel, P. and F. Ulmer (1971). Lokal Pr¨asentierbare Kategorien, volume 221 of

Lecture Notes in Mathematics. Springer-Verlag.

(300)

Girard, J.-Y. (1987).

‘Linear logic’. Theoretical Computer Science, volume 50,

pages 69–108.

(247)

Girard, J.-Y., P. Taylor, and Y. Lafont (1989). Proofs and Types. Cambridge

University Press.

(247, 422)

Godement, R. (1958). Th´eorie des Faisceaux. Hermann.
Goguen, J. A. (1974). ‘Concept representation in natural and artiﬁcial languages:
Int. J. Man-Machine

Axioms, extensions and applications for fuzzy sets’.
Studies, volume 6, pages 513–564.

(117)

(401)

Goguen, J. A. (1978). ‘Abstract errors for abstract data types’. In Formal Descrip-
tion of Programming Concepts, E. J. Neuhold, editor, pages 491–526. North-
Holland.

(222)

Goguen, J. A. (1988).

‘What is uniﬁcation? A categorical view of substitution,
equation and solution’. Technical Report CSLI–88–124, Center for the Study
of Language and Information.

(293)

Goguen, J. A. (1991). ‘A categorical manifesto’. Mathematical Structures in Com-

puter Science, volume 1, pages 49–68.

(xv)

Goguen, J. A. and R. M. Burstall (1986). ‘A study in the foundations of program-
institutions, charters and parchments’.
ming methodology: Speciﬁcations,
In Category Theory and Computer Programming, D. Pitt, S. Abramsky,
A. Poign´e, and D. Rydeheard, editors, volume 240 of Lecture Notes in Com-
puter Science, pages 313–333. Springer-Verlag.
(324)
Goguen, J. A., J.-P. Jouannaud, and J. Meseguer (1985).

‘Operational semantics
for order-sorted algebra’. In Proc. 12th Int. Colloq. on Automata, Languages
and Programming, Napﬂion, Greece, volume 194 of Lecture Notes in Computer
Science, pages 221–231. Springer-Verlag.

(245)

Goguen, J. A., J. W. Thatcher, and E. G. Wagner (1978).

‘An initial algebra
approach to the speciﬁcation, correctness and implementation of abstract data
types’. In Current Trends in Programming Methodology IV, R. Yeh, editor,
pages 80–149. Prentice-Hall.

(245)

Goguen, J. A., J. W. Thatcher, E. G. Wagner, and J. B. Wright (1977).

‘Initial
algebra semantics and continuous algebras’. J. ACM, volume 24, pages 68–95.
(245)

Gray, J. W. (1966). ‘Fibred and coﬁbred categories’. In Proceedings of the Confer-

ence on Categorical Algebra, La Jolla 1965. Springer-Verlag.

(340)

Gray, J. W. (1974). Formal Category Theory: Adjointness for 2-Categories, volume

391 of Lecture Notes in Mathematics. Springer-Verlag.

(140)

Gray, J. W. (1987).

‘Categorical aspects of data type constructors’. Theoretical

Computer Science, volume 50, pages 103–135.

(245, 250)

522

Bibliography

Gray, J. W. (1988). ‘A categorical treatment of polymorphic operations’. In Math-
ematical Foundations of Programming Language Semantics, M. Main, A. Mel-
ton, M. Mislove, and D. Schmidt, editors, volume 298 of Lecture Notes in
Computer Science, pages 2–22. Springer-Verlag.

(140)

Gray, J. W. (1989). ‘The category of sketches as a model for algebraic semantics’.
In Categories in Computer Science and Logic, J. W. Gray and A. Scedrov,
editors, volume 92 of Contemporary Mathematics, pages 109–135. American
Mathematical Society.

(313, 318)

Gray, J. W. (1990).

‘Executable speciﬁcations for data-type constructors’. Dia-

grammes, volume 24, pages 7–31.

(250)

Gray, J. W. (1991).

‘Products in PER: an elementary treatment of the semantics
of the polymorphic lambda calculus’. In Category Theory at Work (Bremen,
1990), volume 18 of Res. Exp. Math., pages 325–340. Heldermann.

(408)

Gray, J. W. and A. Scedrov (1989). Categories in Computer Science and Logic,
volume 92 of Contemporary Mathematics. American Mathematical Society.
(xv)

Guitart, R. and C. Lair (1980). ‘Calcul syntaxique des mod`eles et calcul des formules

internes’. Diagrammes, volume 4.

(219)

‘Existence de diagrammes localement libres 1’.

Guitart, R. and C. Lair (1981).
Diagrammes, volume 6.
Guitart, R. and C. Lair (1982).
Diagrammes, volume 7.

(309)

(309)

‘Existence de diagrammes localement libres 2’.

Gunter, C. (1992). Semantics of Programming Languages. The MIT Press.

(xv,

195, 201)

Hagino, T. (1987). A categorical programming language. PhD thesis, University of

Edinburgh.

(347)

Hagino, T. (1987). ‘A typed lambda calculus with categorical type constructors’. In
Category Theory and Computer Science, D. Pitt, A. Poign´e, and D. Rydeheard,
editors, volume 283 of Lecture Notes in Computer Science, pages 140–157.
Springer-Verlag.

(195, 347)

Halmos, P. (1960). Naive Set Theory. Van Nostrand.
Hindley, J. R. and J. P. Seldin (1986). Introduction to Combinators and λ-Calculus.

(7, 160)

Cambridge University Press.

(208)

Huet, G. (1986).

In Combi-
‘Cartesian closed categories and lambda-calculus’.
nators and Functional Programming Languages, G. Cousineau, P.-L. Curien,
and B. Robinet, editors, volume 242 of Lecture Notes in Computer Science.
Springer-Verlag.

(195)

Huwig, H. and A. Poign´e (1990). ‘A note on inconsistencies caused by ﬁxpoints in
a cartesian closed category’. Theoretical Computer Science, volume 73, pages
101–112.

(215)

Hyland, J. M. E. (1982). ‘The eﬀective topos’. In The L. E. J. Brouwer Centenary

Symposium, pages 165–216. North-Holland.

(384, 409)

Hyland, J. M. E. and A. Pitts (1989).

‘The theory of constructions: Categorical
semantics and topos-theoretic models’.
In Categories in Computer Science
and Logic, J. W. Gray and A. Scedrov, editors, volume 92 of Contemporary
Mathematics, pages 137–199. American Mathematical Society.

(332, 384)

Jacobson, N. (1974). Basic Algebra I. W. H. Freeman.

(18)

(188)
‘On clubs and doctrines’.

Bibliography

523

Ji-Feng, H. and C. A. R. Hoare (1990). ‘Categorical semantics for programming lan-
guages’. In Mathematical Foundations of Programming Semantics, M. Main,
A. Melton, M. Mislove, and D. Schmidt, editors, volume 442 of Lecture Notes
in Computer Science, pages 402–417. Springer-Verlag.

(140, 147)

Johnson, M. (1989). ‘The combinatorics of n-categorical pasting’. Journal of Pure

and Applied Algebra, volume 62, pages 211–225.

(151)

Johnstone, P. T. (1977). Topos Theory. Academic Press.
(384, 387, 388, 390, 396)
Johnstone, P. T. and R. Par´e (1978). Indexed Categories and their Applications.

Lecture Notes in Mathematics. Springer-Verlag.

(330)

Kasangian, S. and S. Vigna (1991). ‘Trees in distributive categories’. In Category
Theory (Como, 1990), volume 1488 of Lecture Notes in Mathematics, pages
237–248. Springer-Verlag.

Kelly, G. M. (1974).

In Proceedings Sydney Category
Theory Seminar 1972/1973, G. M. Kelly, editor, volume 420 of Lecture Notes
in Mathematics. Springer-Verlag.

(343, 344)

Kelly, G. M. (1982). Basic Concepts of Enriched Category Theory. Cambridge

University Press.

(140, 145, 377)

Kelly, G. M. (1982).

‘On the essentially-algebraic theory generated by a sketch’.
Bulletin of the Australian Mathematical Society, volume 26, pages 45–56.
(311)

Kelly, G. M. and R. Street (1973). ‘Review of the elements of 2-categories’. In Pro-
ceedings Sydney Category Theory Seminar 1972/1973, volume 420 of Lecture
Notes in Mathematics. Springer-Verlag.

(140)

Kleisli, H. (1965).

‘Every standard construction is induced by a pair of adjoint

functors’. Proc. Amer. Math. Soc., volume 16, pages 544–546.

(374)

Kock, A. (1972). ‘Strong functors and monoidal monads’. Archiv der Mathematik,

volume 20, pages 113–120.

(376)

Lair, C. (1987).

‘Trames et s´emantiques cat´egoriques des syst`emes de trames’.

Diagrammes, volume 18.

(312)

Lallement, G. (1979). Semigroups and Combinatorial Applications. Wiley.
Lambek, J. (1970). ‘Subequalizers’. Canad. Math. Bull., volume 13, pages 337–349.

(76)

(365)

Lambek, J. (1986). ‘Cartesian closed categories and typed lambda-calculi’. In Com-
binators and Functional Programming Languages, G. Cousineau, P.-L. Curien,
and B. Robinet, editors, volume 242 of Lecture Notes in Computer Science,
pages 136–175. Springer-Verlag.

(208)

Lambek, J. and P. Scott (1984).

In
Mathematical Applications of Category Theory, J. W. Gray, editor, volume 30
of Contemporary Mathematics, pages 145–174. American Mathematical Soci-
ety.

‘Aspects of higher order categorical logic’.

(208)

Lambek, J. and P. Scott (1986). Introduction to Higher Order Categorical Logic,
volume 7 of Cambridge Studies in Advanced Mathematics. Cambridge Univer-
sity Press.

(xv, 102, 187, 195, 208, 211, 212, 384)

Lawvere, F. W. (1963). Functorial Semantics of Algebraic Theories. PhD thesis,

Columbia University.

(56)

Lawvere, F. W. (1966). ‘The category of categories as a foundation for mathemat-
ics’. In Proceedings of the Conference on Categorical Algebra, La Jolla 1965.
Springer-Verlag.

(56, 303)

524

Bibliography

Lawvere, F. W. (1989).

‘Qualitative distinctions between some toposes of gen-
In Categories in Computer Science and Logic, volume 92.

eralized graphs’.
American Mathematical Society.

(11)

Lellahi, S. K. (1989).
pages 1–23.

(245)

‘Categorical abstract data types’. Diagrammes, volume 21,

Lewis, H. R. and C. H. Papadimitriou (1981). Elements of the Theory of Compu-

tation. Prentice-Hall.

(76, 148, 185, 254, 286, 383, 486)

Linton, F. E. J. (1969). ‘Applied functorial semantics’. In Seminar on Triples and
Categorical Homology Theory, volume 80 of Lecture Notes in Mathematics,
pages 53–74. Springer-Verlag.

(116)

Linton, F. E. J. (1969). ‘An outline of functorial semantics’. In Seminar on Triples
and Categorical Homology Theory, volume 80 of Lecture Notes in Mathematics,
pages 7–52. Springer-Verlag.

(116)

L¨uth, C. and N. Ghani (1997).

‘Monads and modular term rewriting’. In Moggi

and Rosolini [1997], pages 69–86.

(376)

Mac Lane, S. (1971). Categories for the Working Mathematician, volume 5 of
(xv, 126, 347, 357, 358,

Graduate Texts in Mathematics. Springer-Verlag.
415, 417)

Mac Lane, S. and I. Moerdijk (1992). Sheaves in Geometry and Logic. Universitext.

Springer-Verlag.

(200, 384, 395, 396)

Main, M., A. Melton, M. Mislove, and D. Schmidt, editors (1988). Mathemati-
cal Foundations of Programming Language Semantics, volume 298 of Lecture
Notes in Computer Science. Springer-Verlag.

(xv)

Makkai, M. (1997).

‘Generalized sketches as a framework for completeness the-
orems, I, II, III’. Journal of Pure and Applied Algebra, volume 115, pages
49–79, 179–212, 241–274.

(312)

Makkai, M. and R. Par´e (1990). Accessible Categories: the Foundations of Cate-
gorical Model Theory, volume 104 of Contemporary Mathematics. American
Mathematical Society.

(102, 312)

Makkai, M. and G. Reyes (1977). First Order Categorical Logic, volume 611 of

Lecture Notes in Mathematics. Springer-Verlag.

(xv, 102, 187, 288, 384)

Manes, E. G. (1986).

‘Weakest preconditions: Categorial insights’.

In Category
Theory and Computer Programming, D. Pitt, S. Abramsky, A. Poign´e, and
D. Rydeheard, editors, volume 240 of Lecture Notes in Computer Science,
pages 182–197. Springer-Verlag.

(276)
Manes, E. G. and M. Arbib (1986). Algebraic Approaches to Program Semantics.

Springer-Verlag.

(xv)

Marti Oliet, N. and J. Meseguer (1991). ‘From Petri nets to linear logic through cat-
egories: a survey’. International Journal of Foundations of Computer Science,
volume 2, pages 297–399.

(417)

Martin, C. E., C. A. R. Hoare, and J. He (1991). ‘Pre-adjunctions in order enriched
categories’. Mathematical Structures in Computer Science, volume 1, pages
141–158.
McLarty, C. (1986).

‘Left exact logic’. Journal of Pure and Applied Algebra, vol-

(147)

ume 41, pages 63–66.

(300, 324)

McLarty, C. (1989).

‘Notes toward a new philosophy of logic’. Technical report,

Case Western Reserve University.

(56)

McLarty, C. (1992). Elementary Categories, Elementary Toposes, volume 21 of

Oxford Logic Guides. Clarendon Press.

(xv, 384, 387, 388, 390, 396)

Bibliography

525

Meseguer, J. and J. A. Goguen (1985).

‘Initiality, induction and computability’.
In Algebraic Methods in Semantics, M. Nivat and J. C. Reynolds, editors.
Cambridge University Press.

(245)

Mikkelson, C. J. (1976). Lattice Theoretic and Logical Aspects of Elementary Topoi,
volume 25 of Aarhus University Various Publications Series. Aarhus Univer-
sity.

(389)

Mitchell, J. C. and P. J. Scott (1989). ‘Typed lambda calculus and cartesian closed
categories’.
In Categories in Computer Science and Logic, J. W. Gray and
A. Scedrov, editors, volume 92 of Contemporary Mathematics, pages 301–316.
American Mathematical Society.

(195)

Moggi, E. (1989).

‘Computational lambda-calculus and monads’. In Proceedings
of the Fourth Annual Symposium on Logic in Computer Science, pages 14–23.
IEEE.

(376)

Moggi, E. (1991). ‘A category-theoretic account of program modules’. Mathematical

Structures in Computer Science, volume 1, pages 103–139.

(376)

Moggi, E. (1991). ‘Notions of computation and monads’. Information and Control,

volume 93, pages 155–92.

(376)

Moggi, E. and G. Rosolini, editors (1997). Category Theory and Computer Science,

7th International Conference. Springer-Verlag.

(xv, 517, 519, 524, 525)

Mulry, P. S. (1992). ‘Strong monads, algebras and ﬁxed points’. In Applications of
Categories in Computer Science, volume 177 of London Mathematical Society
Lecture Notes Series. Cambridge University Press.

(376)

Nico, W. (1983). ‘Wreath products and extensions’. Houston J. Math., volume 9,

pages 71–99.

(340, 344)

Otto, J. R. (1995). Complexity Doctrines. PhD thesis, McGill University.
Pavlovi´c, D. and S. Abramsky (1997). ‘Specifying interaction categories’. In Moggi

(185)

and Rosolini [1997], pages 147–158.

(340, 422)

Peake, E. J. and G. R. Peters (1972). ‘Extension of algebraic theories’. Proceedings

of the American Mathematical Society, volume 32, pages 358–362.

(311)

Permvall, O. (1991). ‘A bibliography on sketches from the computer science point of
view’. Bulletin of the European Association for Theoretical Computer Science,
volume 45, pages 238–255.

(219)

Pierce, B. (1991). Basic Category Theory for Computer Scientists. The MIT Press.

(xv)
Pitt, D. (1986).

‘Categories’.

In Category Theory and Computer Programming,
D. Pitt, S. Abramsky, A. Poign´e, and D. Rydeheard, editors, volume 240 of
Lecture Notes in Computer Science, pages 6–15. Springer-Verlag.

(22)

Pitt, D., S. Abramsky, A. Poign´e, and D. Rydeheard, editors (1986). Category
Theory and Computer Programming, volume 240 of Lecture Notes in Computer
Science. Springer-Verlag.

(xv)

Pitt, D., P.-L. Curien, S. Abramsky, A. M. Pitts, A. Poign´e, and D. E. Rydeheard,
editors (1991). Category Theory and Computer Science (Paris, 1991), volume
530 of Lecture Notes in Computer Science. Springer-Verlag.

(xv)

Pitt, D., A. Poign´e, and D. Rydeheard, editors (1987). Category Theory and Com-
puter Science, volume 283 of Lecture Notes in Computer Science. Springer-
Verlag.

(xv)

526

Bibliography

Pitt, D., D. Rydeheard, P. Dybjer, A. Pitts, and A. Poign´e, editors (1989). Cate-
gory Theory and Computer Science, volume 389 of Lecture Notes in Computer
Science. Springer-Verlag.

(xv)

Pitt, D., D. E. Rydeheard, and P. Johnstone, editors (1995). Category Theory and
(xv, 517)
‘Fuzzy sets do not form a topos’. Fuzzy Sets and Systems,

Computer Science, 6th International Conference. Springer-Verlag.

Pitts, A. M. (1982).

volume 8, pages 101–104.

(400)

Poign´e, A. (1986).

‘Elements of categorical reasoning: Products and coproducts
and some other (co-)limits’. In Category Theory and Computer Programming,
D. Pitt, S. Abramsky, A. Poign´e, and D. Rydeheard, editors, volume 240 of
Lecture Notes in Computer Science, pages 16–42. Springer-Verlag.

(174)

Power, A. J. (1990).

‘A 2-categorical pasting theorem’. Journal of Algebra, vol-

ume 129, pages 439–445.

(151)

Power, A. J. (1990). ‘An algebraic formulation for data reﬁnement’. In Mathemati-
cal Foundations of Programming Semantics, M. Main, A. Melton, M. Mislove,
and D. Schmidt, editors, volume 442 of Lecture Notes in Computer Science,
(141, 376)
pages 402–417. Springer-Verlag.

Power, A. J. (1991).

In Category Theory
(Como, 1990), volume 1488 of Lecture Notes in Mathematics, pages 326–358.
Springer-Verlag.

‘An n-categorical pasting theorem’.

(151)

Power, A. J. and C. Wells (1992). ‘A formalism for the speciﬁcation of essentially
algebraic structures in 2-categories’. Mathematical Structures in Computer
Science, volume 2, pages 1–28.

(140, 141, 312)

Reichel, H. (1987). Initial Computability, Algebraic Speciﬁcations and Partial Al-

gebras. Clarendon Press.

(300)

‘Using category theory to design implicit conversions and
Reynolds, J. C. (1980).
generic operators’.
In Proceedings of the Aarhus Workshop on Semantics-
Directed Compiler Generation, N. D. Jones, editor, volume 94 of Lecture Notes
in Computer Science. Springer-Verlag.

(51)

Rhodes, J. and B. Tilson (1989). ‘The kernel of monoid homomorphisms’. Journal

of Pure and Applied Algebra, volume 62, pages 227–268.

(343, 344, 345)

Rhodes, J. and P. Weil (1989). ‘Decomposition techniques for ﬁnite semigroups i,

ii’. Journal of Pure and Applied Algebra, volume 62, pages 269–284.

(344)

Rosebrugh, R. and R. Wood (1992). ‘Relational databases and indexed categories’.
In Category Theory 1991, R. Seely, editor. American Mathematical Society.
(330)

Rosolini, G. (1987).

‘Categories and eﬀective computation’. In Category Theory
and Computer Science, volume 283 of Lecture Notes in Computer Science.
Springer-Verlag.

(409)

Rosolini, G. (1990). ‘About modest sets’. International Journal of Foundations of

Computer Science, volume 3, pages 341–353.

(408)

FTP from ftp://ftp.cwi.nl/pub/CWIreports/AP/CS-R9652.ps.Z.

Rutten, J. J. M. M. (1996). ‘Universal coalgebra: a theory of systems’. Available by
(254)
‘Automata and coinduction (an exercise in coal-
gebra)’. Available by FTP from ftp://ftp.cwi.nl/pub/CWIreports/SEN/
SEN-R9803.ps.Z.

Rutten, J. J. M. M. (1998).

(254)

Bibliography

527

Rydeheard, D. E. and R. M. Burstall (1985).

‘Monads and theories: A survey
In Algebraic Methods in Semantics, M. Nivat and J. C.

for computation’.
Reynolds, editors. Cambridge University Press.

(292, 376)

Rydeheard, D. E. and R. M. Burstall (1986).

‘A categorical uniﬁcation algo-
rithm’. In Category Theory and Computer Programming, D. Pitt, S. Abram-
sky, A. Poign´e, and D. Rydeheard, editors, volume 240 of Lecture Notes in
Computer Science, pages 493–505. Springer-Verlag.

(293)

Rydeheard, D. E. and R. M. Burstall (1988). Computational Category Theory.

International Series in Computer Science. Prentice Hall.

(xv)

Scott, D. (1972). ‘Continuous lattices’. In Toposes, Algebraic Geometry and Logic,
F. W. Lawvere, editor, volume 274 of Lecture Notes in Mathematics, pages
97–136. Springer-Verlag.

(201, 376)

Scott, D. (1982).

‘Domains for denotational semantics’. In Automata, Languages
and Programming, M. Nielson and E. M. Schmidt, editors, volume 140 of Lec-
(201, 376)
ture Notes in Computer Science, pages 577–613. Springer-Verlag.

Sedgewick, R. (1983). Algorithms. Addison-Wesley.
Seely, R. (1984). ‘Locally cartesian closed categories and type theory’. Proc. Cam-

(278)

bridge Philos. Soc., volume 95, pages 33–48.

(362)

Seely, R. (1987). ‘Categorical semantics for higher order polymorphic lambda cal-

culus’. J. Symbolic Logic, volume 52, pages 969–989.

(362)

Seely, R. (1987). ‘Modelling computations: a 2-categorical framework’. In Proceed-

ings of the Conference on Logic in Computer Science. IEEE.

(140)

Seely, R., editor (1992). Category Theory 1991, volume 13 of Canadian Mathemat-

ical Society Conference Proceedings. American Mathematical Society.

(xv)

Smyth, M. B. (1983). ‘The largest cartesian closed category of domains’. Theoretical
(201)
Smyth, M. B. and G. D. Plotkin (1983). ‘The category-theoretic solution of recursive

Computer Science, volume 27.

domain equations’. SIAM J. Computing, volume 11, pages 761–783.

(376)

Spivey, M. (1989). ‘A categorical approach to the theory of lists’. In Mathematics
of Program Construction, J. L. A. Van de Snepscheut, editor, volume 375 of
Lecture Notes in Computer Science, pages 399–408. Springer-Verlag.

(112)

Street, R. and R. Walters (1973).

‘The comprehensive factorization of a functor’.

Bull. Amer. Math. Soc., volume 79, pages 936–941.

(345)

Tarlecki, A., R. M. Burstall, and J. A. Goguen (1991). ‘Some fundamental algebraic
tools for the semantics of computation III: Indexed categories’. Theoretical
Computer Science, volume 91, pages 239–264.

(330)

Taylor, P. (1989). ‘Quantitative domains, groupoids and linear logic’. In Category
Theory and Computer Science, D. Pitt, D. Rydeheard, P. Dybjer, A. Pitts,
and A. Poign´e, editors, volume 389 of Lecture Notes in Computer Science.
Springer-Verlag.

(393)

Tennent, R. D. (1986). ‘Functor category semantics of programming languages and
logics’.
In Category Theory and Computer Programming (Guildford, 1985),
D. Pitt, S. Abramsky, A. Poign´e, and D. Rydeheard, editors, volume 240 of
Lecture Notes in Computer Science, pages 206–224. Springer-Verlag.

(109)

Thatcher, J. W., E. G. Wagner, and J. B. Wright (1982). ‘Data type speciﬁcation:
Parametrization and the power of speciﬁcation techniques’. ACM Transactions
of Programming Languages and Systems, volume 4, pages 711–732.

(319)

528

Bibliography

Vickers, S. (1992).

‘Geometric theories and databases’.

In Applications of Cat-
egories in Computer Science (Durham, 1991), volume 177 of London Math-
ematical Society Lecture Notes Series, pages 288–314. Cambridge University
(384)
Press.
Volger, H. (1987).

‘On theories which admit initial structures’. Technical report,

Universit¨at Passau.

(304)

Volger, H. (1988). ‘Model theory of deductive databases’. In CSL ’87. First Work-
shop on Computer Science Logic. Proceedings, volume 329 of Lecture Notes in
Computer Science. Springer-Verlag.

(304)

Wadler, P. (1989). ‘Theorems for free!’. In Fourth ACM Symposium on Functional
Programming Languages and Computer Architecture, pages 347–359. Associa-
tion for Computing Machinery.

(376)
Wadler, P. (1992). ‘Comprehending monads’. Mathematical Structures in Computer

Science, volume 2, pages 461–493.

(376)

Wagner, E. G. (1986).

‘Algebraic theories, data types and control constructs’.

Fundamenta Informatica, volume 9, pages 343–370.

(23, 181)

Wagner, E. G. (1986). ‘Categories, data types and imperative languages’. In Cat-
egory Theory and Computer Programming, D. Pitt, S. Abramsky, A. Poign´e,
and D. Rydeheard, editors, volume 240 of Lecture Notes in Computer Science,
pages 143–162. Springer-Verlag.

(181, 318, 319)

Wagner, E. G. (1987). ‘A categorical treatment of pre- and post conditions’. The-

oretical Computer Science, volume 53.

(276)

Wagner, E. G., S. Bloom, and J. W. Thatcher (1985).

‘Why algebraic theories?’.
In Algebraic Methods in Semantics, M. Nivat and J. C. Reynolds, editors.
Cambridge University Press.

(249)

Walters, R. F. C. (1991). Categories and Computer Science. Cambridge University

Press.

(xv, 188, 191)
Walters, R. F. C. (1992).

‘An imperative language based on distributive cate-
gories’. Mathematical Structures in Computer Science, volume 2, pages 249–
256.

‘Some applications of the wreath product construction’. Amer.

(188)
Wells, C. (1976).

Math. Monthly, volume 83, pages 317–338.

(344)

Wells, C. (1980). ‘A Krohn-Rhodes theorem for categories’. J. Algebra, volume 64,

pages 37–45.

(344)

Wells, C. (1988). ‘Wreath product decomposition of categories I’. Acta Sci. Math.

Szeged, volume 52, pages 307–319.

(344)

Wells, C. (1988). ‘Wreath product decomposition of categories II’. Acta Sci. Math.

Szeged, volume 52, pages 321–324.

(344)

Wells, C. (1990). ‘A generalization of the concept of sketch’. Theoretical Computer

Science, volume 70, pages 159–178.

(311, 312)

Wells, C. (1993).

‘Sketches: An outline’. Technical report, Case Western Reserve
University. Available by web browser from http://www.cwru.edu/artsci/
(219)
math/wells/pub/wellspub.html.

Wells, C. (1995).

‘Communicating mathematics: Useful ideas from computer sci-

ence’. American Mathematical Monthly, volume 102, pages 397–408.

(7)

Bibliography

529

Wells, C. and M. Barr (1988). ‘The formal description of data types using sketches’.
In Mathematical Foundations of Programming Language Semantics, M. Main,
A. Melton, M. Mislove, and D. Schmidt, editors, volume 298 of Lecture Notes
in Computer Science. Springer-Verlag.

(222, 243, 245)

Williams, J. H. (1982). ‘Notes on the fp style of functional programming’. In Func-
tional Programming and its Applications, P. H. Darlington, J. and D. Turner,
editors. Cambridge University Press.

(20)

Zilles, S. N., P. Lucas, and J. W. Thatcher (1982).

‘A look at algebraic speciﬁca-

tions’. Technical Report 41985, IBM T. J. Watson Research Center.

(245)

Index

A-action, 360
abuse of notation, 24
acceptor states, 73
accessible category, 304
action, 71, 73, 326
adjoint, 342, 364
adjunction, 343
algebra, 215
algebraic structure, 31, 274
all colimits, 274
all ﬁnite colimits, 274
all ﬁnite limits, 265
all limits, 265
alphabet, 72, 234
amalgamated sum, 275
antisymmetric, 24
application, 13
apply, 109
arity, 239
arrow between fuzzy sets, 392
arrow category, 103, 321
arrow functor, 114, 123, 278
arrow of a category, 16
arrow of a graph, 8
assertion, 269
associative, 18, 97
associative identity (of a triple), 364
associative law, 220
atom, 84
automorphism, 41
∗-autonomous category, 411

barred arrow notation, 3
base (of a cocone), 274
base (of a cone), 150, 214
base category (of a 2-category), 138
base category (of a ﬁbration), 320

base category (of an opﬁbration), 326
bicategory, 56
bijective, 5
binary discrete cocone, 174
binary operation, 156
binary product functor, 344
binary products, 164, 167
binary relation, 24
binary tree, 297, 309
Boolean algebra, 84, 186, 193, 248,

280
bound (variable), 202

canonical binary products, 167
canonical ﬁnite products, 168
canonical injection, 174
carrier, 399
cartesian arrow, 319
cartesian category, 168
cartesian closed, 377
cartesian closed category, 190, 345,

349, 352, 406

cartesian product, 2, 5, 149
cartesian product of arrows, 161
cartesian square, 156
Cat, 65
category, 16, 293
category determined by a monoid, 26
category determined by a poset, 24,

43

category object, 293, 395
category of R-dynamics, 363
category of ﬁnite sets, 18, 84
category of fuzzy sets, 392
category of graphs, 27
category of models, 102, 135, 312
category of monoids, 32, 53, 168

531

532

Index

category of posets, 27, 147
category of semigroups, 32, 43, 78
category of sets, 18, 41, 43, 46, 49,
56, 156, 272, 273, 279, 378

category of sets and partial

functions, 19, 147, 176

category of sets and relations, 19,

147, 176, 406, 412

characteristic arrow, 378
chase a diagram, 96
Chu construction, 413
cleavage, 320
closed (term), 202
closed (under a binary operation), 26
closed monoidal category, 405, 406
closure operator, 365
cocomplete, 274
cocone, 245, 274
codomain, 3, 8
coequalizer, 271, 283
coherent category, 282
coherent functor, 282
colimit, 274, 349, 381
commutative cocone, 274
commutative cone, 263
commutative diagram, 93
commutative semigroup, 24
commutes (of a diagram), 93
compact ∗-autonomous category, 412
compatible family, 296
complement, 279, 362
complemented subobject, 384
complemented subobjects, 279
complete, 194, 265
complete Heyting algebra, 387
component (of a cone), 262
component (of a natural

transformation), 82, 101

composable pair, 16
composite, 16, 101
composite function, 6
composition, 16, 142
computable, 180, 280
cone, 150, 164, 214, 262
confusion, 132, 133, 234, 253
congruence relation, 86, 133
conjunction calculus, 182
connected, 110

connected component, 111
constant, 44, 388
context free grammar, 144, 235
context free rewrite system, 144
continuous, 29
contravariant functor, 68
contravariant hom functor, 69
coordinate, 5
coordinate projections, 149
coproduct, 174
corestriction, 6
coretract, 370
cotriple, 365, 409
counit, 343
covariant, 68
covariant hom functor, 68, 170
CPO, 195
crisp, 394
crossed product, 328
curry, 190, 247

dæmon, 251
decidable, 362
deduction system, 181, 195
derivation tree, 144
derived category, 337
diagonal, 19
diagonal relation, 2
diagram, 92
direct image, 68, 346
directed poset, 373
directly derive, 144
discrete category, 45, 71
discrete cocone, 274
discrete graph, 9
discrete opﬁbration, 326
discrete wreath product, 334
disjoint sum, 279, 381
disjoint union, 185, 325
distributive category, 183, 184, 198
division, 336
domain, 3, 8
domain of a partial arrow, 382
Doolittle diagrams, 275
dual concept, 37
dual notion, 37
dual of a category, 36, 68
duality functor, 411
dualizing object, 412

dynamorphism, 363

eﬀective equivalence relation, 380
eﬀective topos, 400
element-free, 55
empty list, 25
empty path, 15
empty semigroup, 25, 274
empty set, 1, 392
endoarrow, 8
endofunctor, 355
endomorphism, 8, 41
enriched category, 137, 142
epimorphism, 52, 57, 261, 273
equalize, 260
equalizer, 260
equation, 21, 240
equational variety, 240
equivalence of categories, 82, 232,

330

equivalence relation, 272, 380
equivariant map, 72
essentially, 104
evaluation map, 409
excluded middle, 362
existential image, 68
exponential object, 191, 351
extension, 1
external (pair of arrows), 160
external functor, 395
extremal epimorphism, 56, 288

factorization system, 57, 414
factorization systems, 288
factors through, 48
faithful functor, 77, 87
family of sets, 38
FD sketch, 245
ﬁber, 322
ﬁber product, 267
ﬁbration, 320
ﬁbration as generalized product, 322
ﬁeld, 248, 254
ﬁltered poset, 373
Fin, 18, 35, 37, 84
ﬁnal algebra, 248
ﬁnal states, 73
ﬁnitary functor, 358
ﬁnite cone, 291

Index

533

ﬁnite discrete cone, 214
ﬁnite discrete sketch, 245
ﬁnite graph, 9
ﬁnite limit sketch, 291
ﬁnite product, 168, 184
ﬁnite product sketch, 214, 225
ﬁnite state machine, 71, 72, 75, 76,

247, 363

ﬁnite sum, 184
ﬁnitely cocomplete, 274
ﬁnitely complete, 265
ﬁrst projection, 64
ﬁxed point, 29, 208, 355, 356, 368
FL sketch, 291
ﬂat CPO, 211, 385
ﬂatten, 109
FLS category, 282
fold, 109
forgetful functor, 65
formal, 217
formula, 181
FP sketch, 214, 225
FP theory, 231
free, 202, 343
free M -set, 365
free algebra, 237
free category, 39, 67, 75
free FP sketch, 284
free model, 136
free monoid, 25, 33, 75, 339, 363
free monoid functor, 66
full functor, 78
full subcategory, 35
full transformation monoid, 77
function, 3
functional programming language,
111, 169, 176, 195

functional property, 4
functor, 63, 72, 74
functor category, 128, 162, 330
functor induced by a sketch

homomorphism, 312

functorial semantics, 87
fuzzy set, 392

G0, 8
G0-indexed set, 136
global element, 44, 46, 47

534

Index

grammar, 144
graph, 8, 13, 27, 100, 385
graph of a function, 4
graph of sets and functions, 9
GRF, 27
Grf , 27
Grothendieck construction, 324, 396
Grothendieck topology, 387
group, 41
groupoid, 45, 295

hom function, 7
hom functor, 68, 69, 119, 170, 197
hom set, 17, 54, 368
homomorphism of graphs, 11, 27, 95
homomorphism of linear sketches,

127

homomorphism of models, 125, 301
homomorphism of models of a linear
sketch with constants, 131
homomorphism of models of an FP

sketch, 227

homomorphism of monoids, 31, 64,

108

homomorphism of relations, 31
homomorphism of semigroups, 31,

228

homomorphism of sketches, 305
homomorphism of split opﬁbrations,

330

homomorphism of sup semilattices,

175

homomorphism of u-structures, 99
horizontal composite, 116

idempotent, 45, 56, 225, 299
identity, 16
identity element, 25
identity function, 4, 32
identity homomorphism, 12
if-then, 280
image, 4, 305, 451
imposing the relation, 87
inclusion, 174
inclusion function, 4, 32
indexed function, 38
indexed set, 236, 322
indiscrete category, 71
induced natural transformation, 119

induction, 132
inf semilattice, 175
inﬁmum, 152
initial algebra, 233, 250
initial algebra semantics, 124, 130,

238

initial model, 130, 233, 250
initial object, 43, 48, 49, 168, 184,

356

initial term algebra, 296
initial term model, 296
initial topos, 381
injective, 5, 7, 46
input process, 363
integer, 1, 26
interchange law, 117
internal, 160, 197, 375, 384, 395, 400,

401, 407

internal functor, 395
internal language, 205, 384
intersection, 288
inverse, 40
inverse function, 68
inverse image, 68, 268, 346
invertible, 41
isomorphism, 41, 232, 261
isomorphism of semigroups, 32

junk, 132, 133, 233, 253

kernel category, 336
kernel pair, 302, 380
Kleene closure, 25, 33, 109, 144, 340,

361

Kleisli category, 366, 367, 409
Krohn-Rhodes Theorem, 336

λ-calculus, 201, 368
language generated by a context free

grammar, 144

large, 17
large graph , 9
lattice, 175
lazy evaluation, 224
LE sketches, 291
least ﬁxed point, 356
least upper bound, 28, 175
left adjoint, 342
left cancellable, 46

left exact sketches, 291
left inverse, 53
lies over, 320
limit, 263, 349
linear logic, 409, 411
linear sketch, 125, 164
linear sketch with constants, 130
list, 25, 109, 245, 361
local recursion, 362
locally cartesian closed, 354, 379
locally presentable category, 292
locally recursive category, 362
locally small, 17
locos, 362
lower semilattice, 175

M -equivariant, 365
M -extensional, 414
M -separated, 414
M -set, 71
machine, 75
machine in C , 363
map, 4
map lifting property, 67, 237
mapping, 4
mathematical induction, 132
Mod, 102
model of a graph, 100
model of a linear sketch, 125
model of a linear sketch with

constants, 131

model of a signature, 239
model of a sketch, 301, 312
model of an FD sketch, 245
model of an FL sketch, 291
model of an FP sketch, 215, 229, 236
model of an FP theory, 231
modest set, 400
Mon, 32
monic, 46
mono, 46
monoid, 25, 31, 36, 45, 57, 71, 81,

108, 227, 229, 365, 367, 406

monoid action, 336
monoid congruence, 89
monoid homomorphism, 31, 108
monoidal category, 403
monomorphism, 46, 57, 261, 268

Index

535

monotone function, 27, 147, 175
morphism of cones, 263
multiplication of a triple, 364

N, 1, 10, 12
n-ary product, 165
natural equivalence, 103
natural isomorphism, 82, 103
natural numbers, 1, 12, 26, 215, 246,

253, 308, 355

natural numbers object, 177, 199,

233

natural transformation, 101, 106,

119, 227
naturality condition, 101
nearly constant presheaf, 389
node, 8
nondeterminism, 75
nonterminal, 144
notational conventions for sketches,

225, 292

nullary product, 166

object of a category, 16
object of a graph, 8
objectwise products, 163
ω-chain, 28
ω-complete partial order, 28
ω-complete partial ordered object,

210

ω-CPO, 28
one to one, 5
one to one correspondence, 5
1-cell, 142
opcartesian, 320
operations, 125, 239
opﬁbration, 320, 327, 396
opposite of a category, 36, 68
order-enriched category, 143
ordered n-tuple, 2
ordered set, 24, 346

P, 28, 29
P -valued set, 392
parallel pair, 260, 273, 300
parametrized natural numbers, 178
partial arrow, 382
partial arrows representable, 382
partial equivalence relation, 400

536

Index

partial function, 19, 28, 29, 35, 147
partially ordered object, 210
partially ordered set, 42
paste diagrams, 97
path, 15
path category, 39
PER, 400
Pfn, 19, 147, 176
pointed set, 85
Pointwise Adjointness Theorem, 349
pointwise products, 163
polynomial functor, 362
poset, 24, 27, 32, 42, 44, 147, 152,

346

poset-enriched category, 143, 368
postcondition, 269
power object, 379
powerset, 28, 345, 379
powerset functor, 68
precondition, 269
preordered set, 24, 346
preserve a property, 78
preserve limits, 265
preserved by isomorphisms, 41
preserves canonical products, 170
preserves the product, 170
presheaf, 385
product, 36, 149, 150, 165, 176, 344
product category, 64, 70, 321
product cone, 150, 214
product diagram, 150
production, 144
programming language, 20, 28, 75,

87, 111, 149, 169, 176, 177,
180, 195, 243, 390

projection, 5, 149, 150
projection functor, 334
proof, 181
proper subobject, 49
pseudo-inverse, 82
pullback, 267, 281, 288, 352
pullback diagram, 267
pushout, 275

Q, 1
quotient category, 86

R, 1
R-algebra, 356

R-dynamic, 363
rational numbers, 1, 276
real numbers, 1
realizability set, 399
realizability topos, 400
recognized, 73
recognizer, 73
record type, 169, 310
recursion, 29, 30, 360
recursive category, 360
recursive function, 180, 381
recursive set, 383, 384
recursively enumerable, 280, 363,

383, 384

reduce, 109
reﬂect, 79
reﬂexive, 24, 127
regular category, 273, 381
regular cocone, 301
regular epimorphism, 273, 301, 381
regular functor, 273
regular monomorphism, 261
regular sketch, 302
Rel, 19, 147, 176, 406, 412
relation, 2, 4, 19, 147
relation induced by a functor, 86
remainder, 33
representable functor, 118, 171
representative functor, 83
representative subcategory, 43
represents, 118, 160
restriction, 6
restriction functions, 387
retract, 370
rewrite system, 144
right adjoint, 342
right inverse, 53
right regular representation, 335
rules of inference, 182
Russell’s paradox, 2

S -algebra, 215
S-indexed set, 38, 66
satisfy, 240, 315
Sem, 32
semantics, 28, 75, 87, 112, 130, 177,

180, 195, 376, 383, 384

semidirect product, 327

semigroup, 24, 31, 36, 43, 151, 218,

228, 299

semigroup homomorphism, 31
semilattice, 175, 406
sentence, 315
set, 1
Set, 18
set-valued functor, 71, 87, 118, 121,

385
setbuilder notation, 1
shape functor, 333
shape graph, 92
sheaf, 388
signature, 213, 239
simple graph, 10, 293
singleton set, 10
sketch, 213, 214, 245, 301, 305
sketch for categories, 293
sketch for graphs, 126
sketch for monoids, 227, 229
sketch for semigroups, 299
slice category, 37, 97, 322, 345, 352
small, 17
small category, 293
small graph, 9
Smyth–Plotkin category, 369
sort, 239
source, 8
speciﬁcation, 149
split ﬁbration, 321
split idempotent, 45
split monic, 169
split opﬁbration, 326, 396
splitting, 320
stable natural numbers object, 178,

199
stable regular epi, 278
stack, 307
standard wreath product, 335
∗-autonomous category, 411
start state, 72
start symbol, 144
state machine, 247
state space, 71
state transition system, 71, 336
strict ω-CPO, 28
strict functor, 29
strict initial object, 168

Index

537

strict partially ordered object, 210
strictly monotone, 27
string, 25, 144
structure type, 310
subcategory, 35, 65
subfunctor, 113
submonoid, 26
subobject, 49, 132, 376
subobject classiﬁer, 378
subobject functor, 376, 378
substitutable, 202
substitution, 283
sum, 174, 176, 279
sum cocone, 174
sup semilattice, 175, 406
supremum, 28, 175
surjective, 5, 52
switch map, 159
symmetric monoidal category, 403

target, 8
term, 133, 239
term model, 131, 233
terminal (in a context free

grammar), 144
terminal object, 43, 168, 184, 215,

248

ternary product diagram, 164
theory of a linear sketch, 128
theory of an FL sketch, 298
theory of an FP sketch, 231
topos, 377
total category, 320
total order, 295
transducer, 73
transitions, 71
transitive, 24
tree, 254
triangular action, 335
triple, 364
trivial Boolean algebra, 186
true (from 1 to Ω), 378
two-category, 117
2-category, 137
2-cell, 142
2-functor, 143
two-variable hom functor, 69
type, 38
type conversion, 50

538

Index

typed λ-calculus, 202
typed ﬁnite state machine, 75
typed function, 38, 236
typed set, 38

u-structure, 99
unary operation, 99
unary product, 166
underlying functor, 65
underlying linear sketch, 125, 130
underlying set, 24, 99, 339
undirected path, 111
uniﬁcation, 283
unit of a triple, 364
unit of an adjunction, 343
unitary identities (of a triple), 364
universal cone, 263
universal element, 122
universal image, 379
universal mapping property, 67, 151,

340, 343

universal model, 128, 231, 298
universal sum, 280, 381

upper bound, 28
upper semilattice, 175

value of a function, 3
variable element, 46, 55, 384
variable list, 239
variable set, 74
vertex of a cone, 214
vertical composite, 116

weakest precondition, 269
weakly reﬂexive graph, 303
wide, 36
wide intersection, 288
workspace, 63, 160, 329, 333, 384
wreath product, 333

Yoneda embedding, 118, 199
Yoneda functor, 118
Yoneda Lemma, 122

Z, 1
Zk, 33
0-cell, 142

